brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: AccuracySec= is why a systemd timer fires up to a minute late

Systemd
~/tips/tip-systemd-accuracysec

[Timer]

Make a timer fire close to the exact time instead of anywhere in the next minute.

A timer set for 03:00 that runs at 03:00:41 is not broken. Timers have a default accuracy of one minute.

systemd groups timer wakeups to save power, so by default it may fire a timer anywhere within a minute after the set time. For most jobs that is fine. When the exact second matters, tighten it:

[Timer]
OnCalendar=*-*-* 03:00
AccuracySec=1s

systemctl show plain.timer -p AccuracyUSec prints 1min for a timer without the setting, and 1s for one with it.

The man page says you can go as low as 1us, but a second is plenty for anything a shell script does.

Where I would use it: jobs that must run in a narrow window, like grabbing a stream that starts at a fixed time, or a script that compares data with another machine running at the same second.

Do not confuse it with RandomizedDelaySec=, which adds a deliberate random delay on top. If both are set, the delay can be bigger than either. And keep the default on laptops and many timers at once; the grouping is there to reduce how often the CPU has to wake up.

Further reading: systemd.timer man page

More Systemd tips [Service] sudo mkdir -p /etc/systemd/system/service.d [Service] printf 'hunter2' | sudo systemd-creds encrypt --name=dbpass – dbpass.cred systemd-analyze timespan 1h30min All Systemd tips (88) All topics

Link