← Knowledge Base
Server administrationReference note1 min read · updated 2026-11-27

systemd timers as an alternative to cron

A service plus a timer unit, with logging in the journal and catch-up after downtime.

systemdtimersscheduling
# /etc/systemd/system/cleanup.service
[Unit]
Description=Clean temporary files

[Service]
Type=oneshot
ExecStart=/usr/local/bin/cleanup.sh
# /etc/systemd/system/cleanup.timer
[Unit]
Description=Run cleanup daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now cleanup.timer
systemctl list-timers
journalctl -u cleanup.service

Persistent=true runs a missed job after the machine was off. Timers give you logs, dependencies and resource limits that plain cron lacks; cron is shorter for simple jobs.