Notes

Small things about Linux, databases and boring infrastructure.

Systemd timers instead of cron: a short migration note

Cron is fine until a machine reboots at 03:00 and the nightly job simply does not happen. Persistent=true on a systemd timer fixes exactly that, and the logs land in the journal instead of a mailbox nobody reads.

The whole migration was one template unit and one timer per job. The service unit runs as its own user, gets PrivateTmp=yes and a read-only home directory; the timer carries OnCalendar, RandomizedDelaySec and Persistent=true.

The randomised delay turned out to be useful beyond politeness: three jobs that used to start at the same second no longer fight over the same disk.

systemctl list-timers is the part I did not expect to like this much. Seeing the next run and the last result in one table removes an entire category of "did it run?" questions.