Ways to help investigating behavior of periodic scripts

Arthur Chance freebsd at qeng-ho.org
Tue Oct 31 08:03:01 UTC 2017

On 30/10/2017 23:07, Yasuhiro KIMURA wrote:
> Hello all.
> As you know cron(8) executes daily periodic scripts at 03:01 of every
> day and 2 mails are sent to root reporting output of each script. On
> my home server (11.1-RELEASE amd64) these mails usually arrive before
> 03:10. But sometimes they arrive after 03:30 and in rare case after
> 04:00. The delay is not problem for me but I would like to know why it
> happens. So are there any ways to help investigating this delay?
> (Option to make periodic(8) write start and end time of each script to
> syslog, for example.)
> BTW I'm not sure if this ML is best place to ask this question. So
> plese let me know if I should move to other ML.

If you're using the pkg system (which most people do) then the periodic


has at line 60

sleep `jot -r 1 0 3600`

which sleeps for a random time between 0 seconds and 1 hour. This is to
avoid the "thundering herd" problem at the servers, and obviously can
cause the completion time to jitter by up to an hour.

I've also had long delays when a disk was starting to fail, requiring
many retries during the various find operations scattered throughout the
periodic scripts. That usually becomes pretty obvious, especially if you
run smartd.

An amusing coincidence: log2(58) = 5.858 (to 0.0003% accuracy).

More information about the freebsd-questions mailing list