InfraBench / system / cron-systemd

Cron & systemd Timer Lab

Validate 5-field POSIX cron, preview next runs in local time, and generate systemd .service / .timer units

Presets:
-
systemd OnCalendar
-
verify: systemd-analyze calendar "..."
Crontab Line
-
POSIX 5-field schedule
Next 5 Runs (Local Time)
#Scheduled TriggerRelative
systemd Unit Templates
/etc/systemd/system/*.service & .timer

            

Migrating from POSIX Cron to systemd Timers on Modern Linux

While classic crontab remains ubiquitous across Unix systems, modern Ubuntu, Debian, and RHEL servers increasingly favor systemd timers for production jobs. systemd timers integrate cleanly with journalctl logging, cgroup resource limits (MemoryMax=, CPUQuota=), network dependency ordering (After=network-online.target), and missed-run catch-up.

Key Differences Between Cron and systemd OnCalendar

  • Step Syntax: Cron uses */15 for every 15 minutes; systemd calendar expressions use a base value with a slash such as 00/15 for minutes/hours and 01/2 for days/months.
  • Range Operator: Cron separates ranges with a hyphen (1-5 or MON-FRI), whereas systemd uses double dots (Mon..Fri).
  • Verification Built In: Before enabling a timer on a Linux server, always validate the expression directly with systemd-analyze calendar --iterations=5 "Mon..Fri *-*-* 09:00:00".
  • Missed Runs (Persistent=true): If a workstation or on-demand server was powered off during the scheduled time, Persistent=true runs the missed job immediately on next boot. Set Persistent=false for time-sensitive jobs like morning briefings that should not fire unexpectedly hours later.

Frequently Asked Questions

How do I enable and verify a generated systemd timer on Ubuntu/Debian?

Place the two unit files in /etc/systemd/system/, then run sudo systemctl daemon-reload followed by sudo systemctl enable --now my-scheduled-job.timer. Check upcoming triggers with systemctl list-timers --all and inspect logs using journalctl -u my-scheduled-job.service.

What happens if I specify both Day-of-Month and Day-of-Week in Cron?

In standard POSIX/Vixie cron, specifying non-wildcard values in both Day-of-Month (field 3) and Day-of-Week (field 5) creates an OR condition, not an AND condition. For example, 0 9 15 * 1 runs on the 15th of every month AND on every Monday.

Need to audit an entire server crontab at once?

Use the dedicated Crontab Paste Inspector to paste multi-line crontab -l or /etc/cron.d/* files and decode every job in one view.