logoalt Hacker News

compumike • today at 4:34 AM • 3 replies • view on HN

Yes it’s a real effect. I’ve just hardcoded offsets on various jobs:

  * * * * * sleep 17 && …
etc.

That way I still maintain a per-job 60-second cadence consistently (which random would not), but don’t do it right on the top of the minute.


Replies

ahoka • today at 10:23 AM

Yes, using prime numbers are a good way to reduce the risk of multiple timers coinciding, for example a 10s, 30s, 60s period on a freshly restarted node / process.

dylan604 • today at 4:37 AM

That's interesting as it is also visible with a crontab -l so that new scripts can avoid using the same second. However, if you have a farm of machines with the same hardcoded value, they will all still stampede at the same time just not at the top of the minute. By allowing a random value, their start times are slightly offset with in the minute. Is the precise 60s consistent interval really that critical or just that each machine checks once per minute-ish?

Magniquick • today at 4:43 AM

Systemd timers do this natively btw, no need to hardcode And imho are also friendlier.

➕ show 2 replies