You could do this:
sleep $(($(date --date="14-JAN-2015 17:00" +%s) - $(date +%s)))
run command ...
where 14-JAN-2015 17:00
is the date and time you want to wait until.
To run every five minutes, you can consider that the seconds returned by date
will be a multiple of 300 on 5 minute boundaries, so this will calculate the difference between now and the next five minute boundary (returning between 0 and 299):
timeNow=$(date +%s)
sleepTime=$(( ( ( $timeNow + 299) / 300 * 300 ) - $timeNow ))
sleep $sleepTime
If date +%s
is not available, try:
timeNow=$(awk 'END { print systime() }' /dev/null)
Adding: also worked with:
perl -e 'print time(), "\n" '