Plainnotes

A clock jump that ran the job twice

2024-08-14 · 2 min readSystems

A machine booted with a clock half an hour slow; chrony corrected it in one jump, and the backup ran twice within minutes because cron considered one occurrence missed.

Behaviour depends on the implementation: Vixie cron replays missed jobs after a jump, and systemd timers with Persistent=true fire once. The compensation is reasonable; the surprise is not.

Two responses. Keep time from jumping: makestep 1.0 3 in chrony slews small offsets during the first three minutes, and systemd-timesyncd steps gradually anyway.

And make the job idempotent — check whether today's run already happened, with a lock file or a row in the database.

For anything that touches money or reconciliation, idempotency is mandatory. Do not rely on the clock behaving.