Cron Reference: the Five Fields, Special Characters and Gotchas
Cron runs commands on a schedule described in five fields — minute, hour, day of month, month and day of week — followed by the command itself. One line like 30 9 * * 1 means half past nine every Monday morning, and almost every Unix system plus countless schedulers speak this dialect.
1. Fields and allowed values
Minutes span 0 to 59, hours 0 to 23, days of month 1 to 31, months 1 to 12 and weekdays 0 to 7, where both 0 and 7 mean Sunday. A star means every value in that position, so 0 * * * * fires at the top of every hour.
2. Steps, ranges and lists
A slash sets a step — */15 in the minute field means every fifteen minutes — a hyphen sets a range such as weekday 1-5 for Monday to Friday, and commas join lists like 0,30. These compose freely, so 0 9-17 * * 1-5 reads as once an hour through the working day, weekdays only.
3. The day-field OR quirk
When both the day-of-month and day-of-week fields are restricted, cron fires when either matches — not both. A line meant for the first Monday of the month needs extra care, because restricting both fields widens rather than narrows the schedule. Leaving one of them a star keeps the other purely in charge.
4. Presets and environment traps
Shorthands like daily or weekly expand to field patterns, but the classic five-field form travels between systems best. Remember that cron runs with a minimal environment: paths, locales and shell quirks from your terminal do not carry over, so always use absolute paths and test the command by hand first. Build expressions visually and preview the next runs with our cron generator, which computes upcoming dates right in your browser.