Cheat sheet · No. V
Cron.
Five fields — minute through day-of-week — and a command. The traps are step syntax, the way day-of-month and day-of-week combine, and the timezone the daemon runs in.
The reference
# ┌──────── minute (0 - 59) # │ ┌────── hour (0 - 23) # │ │ ┌──── day-of-month (1 - 31) # │ │ │ ┌── month (1 - 12) # │ │ │ │ ┌ day-of-week (0 - 7) Sun = 0 or 7 # │ │ │ │ │ # * * * * * command-to-run
MODIFIERS
*- Every value
5,10,15- List of values
5-15- Range
*/15- Every 15 (units)
0-30/5- Step within range
SUN-SAT- Day-of-week names
JAN-DEC- Month names
PATTERNS
0 * * * *- Top of every hour
*/5 * * * *- Every 5 minutes
0 9 * * 1-5- 9am, weekdays
0 0 1 * *- Midnight, first of month
0 0 * * 0- Midnight, Sundays
@reboot- Once at startup
@daily- = 0 0 * * *
Field notes
Day fields are OR, not AND
0 0 13 * 5 runs on the 13th OR any Friday — not Friday the 13th. When both day fields are set, either match fires.
Steps count from zero
*/15 means every 15 units starting at 0 — :00, :15, :30, :45 — not "every 15 minutes from now".
Mind the timezone
Cron uses the daemon timezone, often UTC. Daylight-saving transitions can skip a run or fire it twice.
Prefer the shortcuts
@daily and @reboot read far clearer than 0 0 * * * — use them whenever the schedule is a standard one.