Cron expression
A five-field schedule string: minute, hour, day of month, month, day of week.
Cron expressions schedule recurring work using five space-separated fields. Each accepts a value, a list, a range, or a step. The two day fields interact in a way that surprises people: when both day-of-month and day-of-week are restricted, the job runs when EITHER matches, not both.
Full guide:
Why */7 in a cron expression is not an even seven-minute interval
— A step applies within each hour and restarts at the top of it. */7 fires at minutes 0, 7, 14, 21, 28, 35, 42, 49 and 56, and then the next fire is minute 0 of the following hour — four minutes later, not seven. A step gives even spacing only when it divides sixty exactly.
Key facts
- The five fields are minute, hour, day of month, month, and day of week, in that order.
- When day-of-month and day-of-week are both restricted, cron runs the job if either matches — the fields are OR-ed, not AND-ed.
- A step like */7 does not divide the hour evenly: it fires at 0, 7, ... 56 and then again at 0, leaving a four-minute gap.
- Cron uses the system timezone, so a job scheduled for 09:00 moves in absolute time when daylight saving changes.
Frequently asked questions
Why does my "first Monday of the month" cron run on the wrong days?
Because restricting both day fields ORs them. "1-7" with "MON" runs on every day from the 1st to the 7th AND on every Monday. Getting first-Monday behaviour requires a day-of-month range plus a weekday check inside the job.
What does */5 mean?
Every fifth value from the start of the range — for minutes, 0, 5, 10 and so on. It divides cleanly only when the step divides the range, which is why */7 in the minute field produces an uneven gap each hour.
Machine-readable copy of this page:
/glossary/cron-expression.md