To execute a script on the next full minute I want to tell the sleep
command to sleep until the next full minute. How can I do this?
Shell sleep until next full minute
shellsleep
shellsleep
To execute a script on the next full minute I want to tell the sleep
command to sleep until the next full minute. How can I do this?
Best Answer
Ask for the date in seconds:
date +%s
and calculate the reminder of the devision with 60 (modulo:%
). If you calculate 60 minus the modulo you get the remaining seconds to the next full minute. You could change this to wait until the next full hour (change 60 to 3600).To just sleep until the next full minute you can even make it shorter (without the modulo):
Also be aware of this question and answer: sleep until next occurence of specific time.