I want my bash script to sleep until a specific time. So, I want a command like \"sleep\" which takes no interval but an end time and sleeps until then.
The \"at\"-d
Use sleep
, but compute the time using date
. You'll want to use date -d
for this. For example, let's say you wanted to wait until next week:
expr `date -d "next week" +%s` - `date -d "now" +%s`
Just substitute "next week" with whatever date you'd like to wait for, then assign this expression to a value, and sleep for that many seconds:
startTime=$(date +%s)
endTime=$(date -d "next week" +%s)
timeToWait=$(($endTime- $startTime))
sleep $timeToWait
All done!