Interview Q&A / Linux & Shell

AdvancedQuick answer1 min readUpdated 3 Oct 2026

What is a systemd timer, and how does it differ from cron?

SHORT ANSWER

A systemd timer is a .timer unit that starts a matching .service on a schedule or after boot. Unlike cron, its output goes to the journal, it can run missed jobs after downtime with Persistent=true, and it supports dependencies and resource limits.

Explain it simply

cron is a simple alarm clock: at 02:00, run this command. A systemd timer is a smarter alarm that is tied to a service unit and to the rest of the system.

Two files are involved:

backup.service holds the job (ExecStart=/opt/backup.sh, Type=oneshot).

backup.timer holds the schedule:

ini
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true

[Install]
WantedBy=timers.target

Then sudo systemctl enable --now backup.timer and check systemctl list-timers.

Advantages: logs in journalctl -u backup.service, Persistent=true runs a missed job after the machine was off, OnBootSec=10min and OnUnitActiveSec=1h give relative timing, and you can set User=, memory limits and ordering.

Cron is still shorter for quick one-liners and is available everywhere, so know both. Test a calendar expression with systemd-analyze calendar "Mon *-*-* 09:00".

Example

bash
sudo systemctl enable --now backup.timer
systemctl list-timers --no-pager | head -3
# NEXT                        LEFT     UNIT          ACTIVATES
# Tue 2026-10-06 02:00:00 IST 15h left backup.timer  backup.service

What to say in the interview

"A timer unit triggers a service on a calendar or monotonic schedule. Compared with cron I get journal logging, Persistent=true for missed runs, and dependency control. I still use cron for simple quick jobs."

Common mistakes

  • Creating only a .timer file without the matching .service.

#linux#systemd#cron

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.