[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: updatedb.mlocate



On Sun 10 Apr 2022 at 12:04:05 (-0400), Greg Wooledge wrote:
> On Sun, Apr 10, 2022 at 03:49:02PM +0100, Darac Marjal wrote:
> > Systemd already supports this.
> > 
> > * AccuracySec=   Specify the accuracy the timer shall elapse with. [...]
> > Within this time window, the expiry time shall be placed at a host-specific,
> > randomized, but stable position.
> > 
> > * RandomizedDelaySec =    Delay the timer by a randomly selected, evenly
> > distributed amount of time between 0 and the specified time value.
> > 
> > 
> > So, "OnCalendar=daily" together with "AccuracySec=24h" *seems* to imply
> > "once per day, but at a random time during the day".
> 
> If that's the case, it's not working correctly on my system.  mlocate
> has OnCalendar=daily and AccuracySec=24h, but before I changed it, it
> was scheduled to run *exactly* at midnight.
> 
> /lib/systemd/system/man-db.timer has OnCalendar=daily and AccuracySec=12h
> and it's scheduled to run *exactly* at midnight.
> 
> /lib/systemd/system/logrotate.timer has OnCalendar=daily and AccuracySec=1h
> and it's scheduled to run *exactly* at midnight.

I think that's because there are two more options whose default values
are zero and false, so they're not specified in our .timer files.

AIUI, setting RandomizedDelaySec=24hr would get you the effect it
seems you expected above, but I seriously think you wouldn't want.

AccuracySec appears to allow several expiring timers to be grouped
into one instant if that instant is within the range allowed, hence
minimising wakeups; RandomizedDelaySec does the opposite, spreading
them out, hence minimising spikes in system load.

If you set RandomizedDelaySec=24hr, then mlocate/whatever would run
at random times of day each day. Setting FixedRandomDelay=true would
make mlocate/whatever run at the same time each day, and that time
would be whatever happened to be chosen on the first day.
(I think buster/241 lacks the fixed one.)

I'm quite happy for mlocate to run (almost) first thing in the morning
when I turn on the computer (assuming I didn't run it beyond midnight
last night).

Cheers,
David.


Reply to: