Cron expressions, explained field by field

The five fields of a cron schedule, the operators that shape them, timezone pitfalls, and the differences between Unix cron and its modern variants.

Five fields, one line

A classic Unix cron expression is five fields separated by spaces: minute (0–59), hour (0–23), day of month (1–31), month (1–12), day of week (0–7, where both 0 and 7 are Sunday). '30 9 * * 1-5' reads as: minute 30, hour 9, any day of month, any month, Monday through Friday — weekday mornings at 09:30.

┌ minute (0-59)
│ ┌ hour (0-23)
│ │ ┌ day of month (1-31)
│ │ │ ┌ month (1-12)
│ │ │ │ ┌ day of week (0-7)
│ │ │ │ │
30 9 * * 1-5

The operators

The subtle one is how day-of-month and day-of-week interact: when both are restricted (not *), cron runs when either matches, not both. '0 0 13 * 5' runs on the 13th of the month and on every Friday — almost never what the author intended.

  • * — any value in the field.
  • , — a list: 1,15 in day-of-month means the 1st and the 15th.
  • - — a range: 1-5 in day-of-week means Monday to Friday.
  • / — steps: */10 in minute means every 10 minutes; 5/20 means starting at 5, then every 20 (5, 25, 45).

Timezone and daylight saving

Cron runs in the system's local timezone unless the implementation supports a CRON_TZ variable or an explicit zone setting. Across daylight-saving transitions, a 02:30 job may run twice in autumn and not at all in spring. For anything that must not double-run — billing, report generation — schedule outside the 01:00–03:00 window or use UTC.

Cron is not always cron

The five-field format is the POSIX classic, but variants diverge. Some parsers add a leading seconds field (Quartz, Spring, AWS EventBridge uses six). Others support names (JAN, MON), L for 'last day of month', W for 'nearest weekday', and # for 'nth weekday'. Kubernetes CronJobs and GitHub Actions use plain five-field cron — but GitHub Actions runs it in UTC, always.

When an expression 'works locally' but behaves differently in production, the first question is which dialect the scheduler speaks. The safest expressions use only numbers and the four basic operators.

References

Related tools