New answers tagged

2

#!/bin/bash NOW=$(date +"%s") SOON=$(date +"%s" -d "3:00 PM Sun") INTERVAL=$(($SOON-$NOW)) sleep $INTERVAL GNU date allows you to specify the format of the output, as well as the date to display. So I use the format string "%s" to get the time in seconds since the epoch, and the same for the arbitrary time using the -d paramater. Get the difference, and ...


7

if the user is allowed to use at command, this is the perfect use for that: $ at 08:00 022116 at> myscript.sh at> <----------- ctrl-d here job 9 at 2016-02-21 08:00 if you get a message like "user blah is not able to run at", ask the syadmin to add this user to at.allow file or remove from at.deny file, depending on how it is used in your ...


2

POSIX guarantees you that a successful, uninterrupted sleep will sleep at for least as long as you request: http://pubs.opengroup.org/onlinepubs/009604599/functions/sleep.html On Linux, it may take longer due to 1) rounding 2) waiting on the scheduler to put the process/thread on the CPU 3) time spent in a stopped state: ...


5

The definition of sleep(3) allows for the call to return before, at, or after the time specified: DESCRIPTION sleep() makes the calling thread sleep until seconds seconds have elapsed or a signal arrives which is not ignored. So we have these possible scenarios The call is interrupted with an uncaught signal. sleep() returns immediately and ...



Top 50 recent answers are included