Cron has scheduled tasks on Linux for decades, but modern distributions ship a more powerful alternative that many administrators overlook: systemd timers. Timers integrate with the service manager, so scheduled jobs get proper logging in the journal, dependency handling, missed-run catch-up and resource controls for free. In this guide you will learn how systemd timers work, convert a classic cron job into a timer, and use the built-in timers every systemd system already runs. This article covers How to Schedule Tasks with Systemd in detail.
Why Replace Cron with Systemd Timers? – How to Schedule Tasks with Systemd
Cron is simple and universal, but it has real limitations on servers. If the machine is off — or rebooting for kernel updates — when a cron job should run, the job is silently skipped. Cron output disappears into local mail spools nobody reads, and there is no standard way to say “run this only after the network is up” or “run it once, five minutes after boot”. Systemd timers solve all of these problems:
- Persistent timers run missed jobs at the next boot with
Persistent=true - Output goes to the journal, readable with
journalctl -u - Timers trigger real systemd services, so dependencies, ordering and sandboxing options apply
- Randomized delays spread load across a fleet
How Systemd Timers Work – How to Schedule Tasks with Systemd
A timer consists of two unit files with the same name:
- A .service unit describing what to run (the same kind of unit you already know)
- A .timer unit describing when to run it
When the timer fires, systemd starts the matching service. See which timers your system already has:
systemctl list-timers --all
You will find timers for log rotation, man-page indexing, temporary file cleanup and package database updates — proof that your distribution already trusts this mechanism for its own housekeeping.

Step 1: Create the Service Unit
Suppose you want to run a backup script every night instead of the cron entry we used to automate Linux backups with rsync and cron. First create the service at /etc/systemd/system/nightly-backup.service:
[Unit]
Description=Nightly backup job
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
User=root
Type=oneshot is the right choice for jobs that run a command and exit, which is exactly what scheduled scripts do.
Step 2: Create the Systemd Timer
Create /etc/systemd/system/nightly-backup.timer next to it:
[Unit]
Description=Run nightly backup at 02:30
[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true
RandomizedDelaySec=10m
Unit=nightly-backup.service
[Install]
WantedBy=timers.target
The key directives are:
OnCalendar— a calendar expression;daily,weekly,Mon..Fri 09:00and*-*-01 00:00:00(monthly) are all validPersistent=true— if the server was off at 02:30, the job runs immediately at bootRandomizedDelaySec— spreads the start time to avoid thundering herds
Validate a calendar expression before using it:
systemd-analyze calendar "*-*-* 02:30:00"
systemd-analyze calendar "Mon..Fri 09:00"
Step 3: Enable and Verify the Timer
Reload systemd, enable the timer, and confirm it is scheduled:
sudo systemctl daemon-reload
sudo systemctl enable --now nightly-backup.timer
systemctl list-timers nightly-backup.timer
systemctl status nightly-backup.timer
To test the job itself without waiting for the schedule, start the service directly:
sudo systemctl start nightly-backup.service
journalctl -u nightly-backup.service -n 50
Every run, including failures, is in the journal — a huge improvement over hunting through cron mail. If your journal grows too large over time, see our guide on how to clear the journal log safely.
Monotonic Timers: Run After Boot
Calendar timers are not the only kind. Monotonic timers count from a reference point such as boot time:
[Timer]
OnBootSec=5min
OnUnitActiveSec=6h
Unit=health-check.service
This runs a health check five minutes after every boot and then every six hours afterwards — something cron simply cannot express. The systemd.timer manual page lists all available time directives.
Troubleshooting
Timer listed but never fires: check that it is enabled (systemctl is-enabled) and that the [Install] section with WantedBy=timers.target exists; without it, enable silently does nothing.
“Failed to start” in the journal: the service failed, not the timer. Run the service manually and fix the script path or permissions shown in journalctl -u output.
Wrong next-run time: your OnCalendar expression is probably broader than intended. Test it with systemd-analyze calendar, which prints the next elapse time.
User Timers for Unprivileged Jobs
Everything above used system timers running as root, but systemd timers also work per user. Place unit files in ~/.config/systemd/user/ and manage them with systemctl --user — no sudo required. This is ideal for developer housekeeping jobs such as cleaning build caches or syncing dotfiles. For user timers to run while you are logged out, enable lingering once with sudo loginctl enable-linger youruser; without it, user timers only fire during an active login session. The split is clean: root-owned jobs in /etc/systemd/system, personal jobs in your home directory, and identical tooling and logging for both.
Conclusion
Systemd timers give scheduled jobs first-class status on modern Linux servers: persistent catch-up runs, journal logging, dependencies and boot-relative schedules. You do not need to migrate everything at once — start with your most important job, verify it in the journal, and move the rest of your crontab over at a comfortable pace.