5 ms·
> "Are you wondering why I used 2:17 am? Well, there is a simple explanation for that: almost everybody else did not." Reminds me of the "fair dice": https://x
by Walkman 10y ago
> "Are you wondering why I used 2:17 am? Well, there is a simple explanation for that: almost everybody else did not."
Reminds me of the "fair dice": https://xkcd.com/221/ https://xkcd.com/221/
- mikeash 10y agoSeems like cron really should have a way to run a job at a random moment between two points in time. I searched around some and all the solutions involve terrible hacks like prefacing your command with /bin/sleep $((RANDOM\%3600)).
- rlpb 10y agosystemd can do this - see RandomizedDelaySec in systemd.timer(5). The hack you mention for cron doesn't seem particularly bad though.
- digi_owl 10y agoTerrible hack, or building a solution from parts, i can't really tell the diff.
- mikeash 10y agoI think what turns it into "terrible hack" for me is the fact that it won't properly handle the situation where the machine reboots after firing the cron job and before the sleep completes. Having an extra process sitting around for potentially hours doing nothing but waiting also seems ugly. Neither is particularly important though....
- stevekemp 10y agoThere's a good writeup here of ways in which people "should" wrap cron-jobs: https://www.ctl.io/developers/blog/post/cron-in-production https://www.ctl.io/developers/blog/post/cron-in-production