3 ms·
Or you prefix your command / script with sleep and a randomlly generated 1h value!
by coldtea 6y ago
Or you prefix your command / script with sleep and a randomlly generated 1h value!
- TimWolla 6y agoThis works, but compared to using systemd it has the drawback that the range of possible times is anchored to the configured time in cron. The systemd timer example I gave causes the next cycle to start when the previous job finished. So if it initially runs the script between 0:00 and 1:00 and the script takes 1.5 hours to finish then the next run will be between 1:30 and 2:30 the next day, instead of 0:00 and 1:00.
- MayeulC 6y ago> So if it initially runs the script between 0:00 and 1:00 and the script takes 1.5 hours to finish then the next run will be between 1:30 and 2:30 the next day Shouldn't it be between 1:30 ans 3:30? I'm just nitpicking, of course, that's a nice solution.
- TimWolla 6y agoYes, you are correct. The script ends no later than 2:30 and then there's a delay of up to 1 hour.