[systemd-devel] Understanding the effect of AccuracySec=

Andrei Borzenkov arvidjaar at gmail.com
Sat Aug 17 06:22:00 UTC 2024


On 16.08.2024 12:43, Windl, Ulrich wrote:
> Hi!
> 
> I have defined a time using
> 
> [Timer]
> OnCalendar=daily
> AccuracySec=6h
> Persistent=true
> 
> And the idea was to run the unit daily, but it's rather unimportant when, just nout in prime hours.
> 
> The man page says:
> 
>         AccuracySec=
>             Specify the accuracy the timer shall elapse with. Defaults to 1min.
>             The timer is scheduled to elapse within a time window starting with
>             the time specified in OnCalendar=, OnActiveSec=, OnBootSec=,
>             OnStartupSec=, OnUnitActiveSec= or OnUnitInactiveSec= and ending
>             the time configured with AccuracySec= later. Within this time
>             window, the expiry time will be placed at a host-specific,
>             randomized but stable position that is synchronized between all
>             local timer units. This is done in order to distribute the wake-up
>             time in networked installations, as well as optimizing power
>             consumption to suppress unnecessary CPU wake-ups. To get best
>             accuracy, set this option to 1us. Note that the timer is still
>             subject to the timer slack configured via systemd-system.conf(5)'s
>             TimerSlackNSec= setting. See prctl(2) for details. To optimize
>             power consumption, make sure to set this value as high as possible
>             and as low as necessary.
> 
> So I expected that multiple instances of the timer would be "spread", but instead I see all instances started at 00:00:01.

It sounds like you want RandomizedDelaySec, not AccuracySec.

> So did I misunderstand, or is it some kind of bug with timer instances? Systemd being used is old systemd-228-157.60.1.x86_64 in SLES 12 SP5...
> 
> Or is
> 
> [Install]
> WantedBy=timers.target
> 
> Causing this?
> 
> 
> Kind regards,
> Ulrich
> 
> 



More information about the systemd-devel mailing list