Cron · 5 — minute, hour, day-of-month, month, day-of-week
Cron field order
A five-field cron expression runs minute, hour, day-of-month, month and day-of-week, in that order.
Key facts
| Fields | 5 — minute, hour, day-of-month, month, day-of-week |
|---|---|
| Minute | 0–59 |
| Hour | 0–23 (24-hour clock) |
| Day of month | 1–31 |
| Month | 1–12 |
| Day of week | 0–7, where both 0 and 7 mean Sunday in Vixie cron |
| Seconds | Not present in the five-field form |
| Standard reference | crontab(5) in Vixie cron and cronie |
Reading a field from left to right
The first field is the minute within the hour, not the hour. 30 2 * * * therefore means 02:30, while 2 30 * * * is invalid because 30 is not a legal hour. Each field accepts a list, a range or a step, so the expression stays compact even for irregular schedules.
A day-of-month value above the length of a month simply never matches in that month: 0 0 31 * * runs in January, March, May, July, August, October and December, and silently skips the short months. It does not “roll over” to the first of the next month.
The trailing part of the line
Everything after the fifth field is the command, passed to the shell, so spaces inside it do not need escaping in a crontab. Environment assignments can appear before the schedule, and % in the command is special in crontab: it is converted to a newline unless escaped as \%.
Because there is no seconds field, a job cannot be scheduled at second granularity with the five-field form. Sleep at the start of the command or use a timer that supports seconds if that precision is required.
Frequently asked questions
Is the first cron field minutes or seconds?
In the five-field form it is minutes. Seconds appear only in dialects such as Quartz and Spring, where a sixth field is prepended.
Can cron run a job every 30 seconds?
Not with a five-field expression. The minimum interval is one minute; sub-minute scheduling needs a different scheduler or a loop inside the command.
Does day 31 roll over into the next month?
No. A day-of-month that does not exist in a given month simply does not match, so the job is skipped that month.