Cron Atlas

Standard cron expressions

Five fields, as read by the cron daemon on Linux and defined by POSIX. The rule that catches people is how the two day fields combine.

minute30
hour4
day of month1st, 15th
monthevery month
day of weekFri

At 04:30, on the 1st and the 15th of the month, or on Fridays.

Next 10 runs

Clock changes

In the other dialects

“Same schedule” means the same clock times. Schedulers still treat a clock change differently, as the table on the home page shows.

Keyboard: / edit the expression, 1 to 6 change dialect, t time zone, n next clock change, c copy the link, Esc leave a field.

Fields

FieldValuesSpecial characters
Minute0–59* , - /
Hour0–23* , - /
Day of month1–31* , - /
Month1–12 or JAN–DEC* , - /
Day of week0–7, where 0 and 7 are Sunday, or SUN–SAT* , - /

Special characters

*
Every value in the field.
,
A list: 1,15.
-
An inclusive range: 9-17. A backwards range such as 22-2 is rejected.
/
A step over a range or star: */15, 0-23/2. 20/15 is not valid here; write 20-59/15.
@daily
Nicknames for common schedules: @yearly, @annually, @monthly, @weekly, @daily, @hourly and @reboot.

The two day fields

If day of month and day of week are both restricted, the job runs when either matches. 30 4 1,15 * 5 runs at 04:30 on the 1st, on the 15th and on every Friday. POSIX and the crontab man page both say so.

Time zones

The machine’s local zone, unless the crontab sets CRON_TZ, which cronie supports. It is not part of POSIX, so check your cron.

Clock changes

The man page says missing times never match and repeated times run twice, and that is what this page shows. The daemon can do better: cronie’s main loop catches up fixed-time jobs after a forward jump and does not repeat them after a backward one, although it warns that jobs using CRON_TZ can still be missed or run twice. Treat runs next to a clock change as implementation-specific.

Gotchas

  • Vixie-derived cron decides a day field is unrestricted by its first character being *. So 0 0 */2 * 1 needs both fields to match, which is the opposite of what the OR rule suggests. The Go library behind Kubernetes reads the same expression as OR.
  • POSIX itself has no steps or names. */5 is a universal extension, not part of the standard.
  • % in the command becomes a newline unless escaped. It lives in the command rather than the schedule, but it is why date +%F breaks in a crontab.
  • cronie also has a random range, ~, picked when the crontab loads. No tool can predict those runs, and this one says so instead of guessing.

Examples to try

Sources

Other dialects