Re: Should we add jitter to cron(8) ?

From: Miroslav Lachman <000.fbsd_at_quip.cz>
Date: Mon, 02 Nov 2026 11:56:12 UTC
On 02/11/2026 12:25, Poul-Henning Kamp wrote:
> Embedded systems using cron(8) are starting to cause macroscopic
> effects at the top of the minute:
> 
> 	https://www.fz-juelich.de/en/news/archive/press-release/2026/mystery-of-60-second-fluctuations-in-power-grids-solved
> 
> That indicates that we should add jitter to cron(8).
> 
> I can see three ways to do it:
> 
> A) By default cron(8) waits [0...N] seconds before executing commands.
>     This can be disabled with a command line option.
>     For a number of reasons which we can hash later, I suggest N=30
> 
> B) Same as A), but the command line option enables jitter.
> 
> C) Same as A), but with additional crontab(5) syntax to say "dont
>     jitter this particular entry".
> 
> I would argue that A is the proper choice.
> 
> Comments ?
We already have that. Or do you mean something else?

-j jitter
  Enable time jitter.  Prior to executing commands, cron will sleep
  a random number of seconds in the range from 0 to jitter.  This
  will not affect superuser jobs (see -J).  A value for jitter must
  be between 0 and 60 inclusive.  Default is 0, which effectively
  disables time jitter.

  This option can help to smooth down system load spikes during
  moments when a lot of jobs are likely to start at once, e.g., at
  the beginning of the first minute of each hour.

-J rootjitter
  Enable time jitter for superuser jobs.  The same as -j except
  that it will affect jobs run by the superuser only.


cron_flags="-j 20 -J 20" in rc.conf should do the trick


Best regards
Miroslav Lachman