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. unicorn:~$ systemctl list-timers | grep 00:00 Mon 2022-04-11 00:00:00 EDT 13h left Sun 2022-04-10 00:00:00 EDT 10h ago logrotate.timer logrotate.service Mon 2022-04-11 00:00:00 EDT 13h left Sun 2022-04-10 00:00:00 EDT 10h ago man-db.timer man-db.service Further evidence in the form of timestamps on files in /var/log: -rw-r----- 1 root adm 1559363 Apr 9 23:59 auth.log.1 -rw-r----- 1 root adm 568405 Apr 9 23:59 mail.log.1 -rw-r----- 1 root adm 568405 Apr 9 23:59 mail.info.1 -rw-r----- 1 root adm 0 Apr 10 00:00 mail.warn -rw-r----- 1 root adm 0 Apr 10 00:00 debug -rw-r----- 1 root adm 740788 Apr 10 00:00 syslog.1 -rw-r----- 1 root adm 46660 Apr 10 00:00 daemon.log.1 Previously I had noted that the mlocate db timestamp was at midnight as well.