Cron and systemd timers are the two dominant task-scheduling mechanisms on Linux systems, covering everything from simple hourly scripts to complex dependency-aware background jobs. Cron has been the standard for decades and works on virtually every Unix-like system with a minimal learning curve, while systemd timers integrate tightly with the systemd ecosystem to provide structured logging, dependency ordering, and reliable catch-up on missed runs. The critical mental model to carry into both tools: they run in minimal, non-interactive environments with restricted PATH and no shell profile loaded β the most common source of "works in terminal, breaks in cron" failures.
What This Cheat Sheet Covers
This topic spans 17 focused tables and 140 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Cron Field Syntax
The five-field crontab time expression is the foundation of every cron job. Each field position controls a distinct time unit, and understanding how they combine β including wildcards, ranges, lists, and step values β lets you express any recurring schedule in a single compact line.
| Command | Example | Description |
|---|---|---|
# MIN HOUR DOM MON DOW CMD | Five fields in order: minute (0β59), hour (0β23), day-of-month (1β31), month (1β12), day-of-week (0β7, 0 and 7 = Sunday). | |
* * * * * /path/to/cmd | β’ Matches every valid value for that field β’ * in minute means every minute | |
0 3 * * * /usr/bin/backup.sh | β’ Runs once at 3:00 AM every day β’ only exact match triggers the job | |
0 8,12,18 * * * /script.sh | Runs at 8 AM, 12 PM, and 6 PM β comma separates a list of values within one field. | |
0 9-17 * * 1-5 /script.sh | β’ Runs at the top of every hour from 9 AM to 5 PM, Monday through Friday β’ hyphen defines a contiguous range. |