notexcitex

systemd timers instead of cron

2 October 2026

Cron is fine until a job fails quietly. A timer plus a oneshot service gives you logs, exit codes and a clear last run for free.

# /etc/systemd/system/backup.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh

# /etc/systemd/system/backup.timer
[Timer]
OnCalendar=*-*-* 03:15
RandomizedDelaySec=10m
Persistent=true

[Install]
WantedBy=timers.target

Persistent=true runs a missed job after the machine was off. systemctl list-timers shows the next and the last run, and journalctl -u backup keeps the output.