notes.

Replacing cron with systemd timers on a 1 GB VM

Sep 21, 2026 · linuxsystemd

cron has served me well for a decade, but on small VMs I kept hitting the same three problems: jobs silently failing, jobs not running after a reboot, and every machine firing its backups at exactly 03:00. systemd timers solve all three with very little ceremony.

A service and a timer

The job itself is an ordinary oneshot service:

# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
Nice=10
IOSchedulingClass=idle

The schedule lives in a timer with the same name:

# /etc/systemd/system/backup.timer
[Unit]
Description=Run backup nightly

[Timer]
OnCalendar=*-*-* 03:00:00
RandomizedDelaySec=45min
Persistent=true

[Install]
WantedBy=timers.target

What each line buys you

SettingWhy it matters
Persistent=trueIf the VM was off at 03:00, the job runs at next boot.
RandomizedDelaySecSpreads load when many machines share a schedule.
Nice / IOSchedulingClassKeeps a 1 GB box responsive while the job runs.

Finding out what happened

systemctl list-timers
journalctl -u backup.service --since yesterday

That second command is the real reason I switched: output and exit codes land in the journal by default, so "did last night's backup work?" is a one-liner instead of an archaeology project.