Skip to content

general guide

Cron Syntax Explained: The Five Fields, and the Four Traps That Make a Job Fire Wrong

A cron expression is five fields that each expand into a set of allowed numbers, and a job fires when the current minute is in all five sets at once. That model is simple enough to hold in your head, which is exactly why the traps are so effective: a step does not mean a steady interval, two day fields are combined with OR rather than AND, a schedule can be perfectly valid and never fire, and the numbers mean whatever timezone the machine running the job happens to use. None of these produce an error message. They produce a job that runs at 21:00 and then 00:00, or a backup that silently never happens. This guide walks the grammar and then each trap with the actual expanded sets, so you can check a schedule by reading it instead of waiting a week to find out.

Updated December 2, 2026 · 16 questions answered

Key takeaways

  • Standard cron has exactly five fields in a fixed order: minute 0-59, hour 0-23, day of month 1-31, month 1-12, day of week 0-7. There is no seconds field and no year field.
  • A step restarts at the field boundary. Star slash 7 in the hour field gives 0, 7, 14 and 21, so the last gap of the day is three hours, not seven.
  • When both day-of-month and day-of-week are restricted they are combined with OR, not AND. The job fires on the 13th or on any Friday, whichever comes first.
  • Both 0 and 7 mean Sunday. Month and weekday names work only as three-letter abbreviations, so JAN resolves and JANUARY does not.
  • A schedule can parse cleanly and never fire: day 31 of April is impossible, and day 29 of February only exists in a leap year.
  • The field values are local to the machine running the job. A browser-based parser shows your timezone; most servers run cron in UTC, and the two can differ by a whole day.

Five Fields, in a Fixed Order, Each Expanding to a Set

The whole grammar is five space-separated fields, left to right: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7). Each field expands into a set of integers. The scheduler walks forward minute by minute and fires when the current minute, hour, day, month and weekday are all members of their respective sets. There is no sixth field for seconds and no seventh for a year — if you have seen those, you were looking at Quartz, Spring or systemd, not cron.

The mental shift that makes everything else click is that a field is a set membership test, not an interval. */15 in the minute field does not mean "wait fifteen minutes after the last run". It means "the set {0, 15, 30, 45}", and the job fires whenever the wall clock lands on one of those numbers. That distinction is the root of three of the four traps below.

The cron parser expands every field for you and shows the resulting sets alongside a plain-English sentence and the next eight fire times. That is the fastest way to settle what an expression actually does: read the expanded set rather than reasoning about the shorthand. It runs entirely in your browser, so a schedule copied out of a production config never leaves your machine.

Field count is checked before anything else, and the error tells you the count it found. A four-field expression reports that standard cron uses five fields and that this one has four. A six-field Quartz expression reports six. @daily and @reboot report one, because they are a single token — they are nicknames understood by some cron daemons, not part of the five-field grammar, and this parser does not expand them.

Out-of-range values are rejected individually and named: minute 60 reports that 60 is out of range 0-59, hour 24 reports 0-23, day 32 reports 1-31, month 13 reports 1-12, weekday 8 reports 0-7. A backwards range such as 5-1 is rejected as running backwards, and a step of zero is rejected because it would never advance. These are the easy failures. The hard ones all parse successfully.

The Operators: Star, Value, Range, List, Step and Names

Six forms cover everything. * means the whole range of the field. A bare number means that one value. a-b means every integer from a to b inclusive. a,b,c is a list, and each item may itself be any of the other forms. /n is a step, applied either to * or to a range. And in the month and weekday fields, three-letter names stand in for numbers.

Steps on a range are the least surprising: 1-10/3 in the minute field expands to 1, 4, 7, 10 — start at the range's lower bound and add the step until you pass the upper bound. 0-30/10 gives 0, 10, 20, 30. Note that the upper bound is included only if the arithmetic lands on it exactly; 1-10/4 gives 1, 5, 9 and stops, because 13 is past 10.

A step on a lone value is a widely supported extension rather than part of the original grammar: 5/10 in the minute field means "start at 5, step by 10, up to the field maximum", giving 5, 15, 25, 35, 45, 55. Some cron implementations reject it. If you need portability across daemons, write the equivalent range explicitly as 5-55/10 — same set, no extension required.

Names are case-insensitive but strictly three letters. JAN, jan and Jan all resolve to month 1; MON-FRI resolves to weekdays 1 through 5. Full names do not work: JANUARY is rejected as not being a number, and so is MONDAY. This is a common copy-paste failure when moving a schedule between a Quartz-style scheduler, which accepts full names, and a plain crontab, which does not.

Weekday numbering has one deliberate redundancy: both 0 and 7 mean Sunday. So 0-7 covers the entire week and is equivalent to *, and a range written 1-7 means Monday through Sunday rather than Monday through Saturday. If you are translating a schedule from a system where Sunday is 1, every weekday number shifts, and that is a silent off-by-one-day error rather than a parse failure.

Trap One: A Step Restarts at the Field Boundary

Because a field is a set built from its own minimum, a step that does not divide the field's span produces an uneven cadence. The set is generated from the bottom of the range and simply stops at the top; it does not wrap around and continue.

Measured in the minute field: */15 gives 0, 15, 30, 45 and the gaps are 15, 15, 15, 15 — even, because 15 divides 60. */25 gives 0, 25, 50 and the gaps are 25, 25, 10. The job runs at :50 and then again ten minutes later at :00. */7 gives 0, 7, 14, 21, 28, 35, 42, 49, 56 and the final gap is 4 minutes, from :56 to :00.

The hour field behaves the same way and the effect is larger. 0 */7 * * * expands to hours 0, 7, 14, 21 — gaps of 7, 7, 7, 3. Anyone reading that expression as "every seven hours" expects a steady cadence and gets a three-hour gap overnight. If you genuinely need a fixed seven-hour interval, cron cannot express it: the day is 24 hours and 7 does not divide 24. Use a divisor of 24 (1, 2, 3, 4, 6, 8, 12) or run the job from a scheduler that tracks elapsed time instead of wall-clock fields.

Two degenerate cases are worth recognising on sight. */60 in the minute field expands to {0} alone, because the next value would be 60 and that is outside the range. */90 also expands to {0}. Both are therefore identical to writing 0, and both fire once an hour — not once every 60 or 90 minutes in the sense of a drifting interval. They happen to be correct for "on the hour", but only by accident.

The general rule: a step is only a true interval when it divides the field's span evenly. Minutes and seconds divide by 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30. Hours divide by 1, 2, 3, 4, 6, 8, 12. Anything else gives you a short gap at the boundary, and the parser's expanded set will show it to you immediately.

Trap Two: Day-of-Month and Day-of-Week Are ORed, Not ANDed

This is the trap that catches almost everyone, because it contradicts how every other pair of fields behaves. Minute, hour and month are combined with AND. But when both day-of-month and day-of-week are restricted — that is, neither is * — the two day tests are combined with OR. The job fires if either one matches.

Measured from 1 December 2026, the expression 0 0 13 * 5 fires at midnight on 4 December, 11 December, 13 December, 18 December, 25 December, 1 January, 8 January and 13 January. The Fridays are the 4th, 11th, 18th and 25th; the 13th is a Sunday that month. It is the union of the two sets, not the intersection. Read as English, "on the 13th and on Fridays" is what most people intend, and it is not what they get.

The rule is conditional, which is what makes it survivable. If day-of-month is *, only the weekday test applies: 0 0 * * 5 fires every Friday and nothing else. If day-of-week is *, only the day-of-month test applies: 0 0 13 * * fires on the 13th of every month. The OR only engages when you have narrowed both.

So the fix is to leave one of the two day fields as *. If you want "the 13th, but only when it is a Friday", cron cannot express that directly — you would schedule 0 0 13 * * and have the job itself check the weekday and exit early. That is not a workaround to be embarrassed about; it is the standard pattern, because the condition is genuinely outside the grammar.

The parser states the rule in its own output rather than leaving you to discover it: when both day fields are restricted, the description ends with a note that day-of-month and day-of-week are combined with OR. Checking that sentence is a two-second habit that prevents a whole class of scheduling bug.

Trap Three: Valid Schedules That Never Fire

A cron expression is validated field by field, against the field's own range. Nothing checks whether the combination is possible on a real calendar. So 0 0 31 4 * — midnight on the 31st of April — parses perfectly, expands to a valid set, and can never fire, because April has 30 days. The same applies to the 31st of June, September and November, and to the 30th of February.

Leap day is the subtler version. 0 0 29 2 * is a real schedule that fires roughly once every four years. It is not invalid, and a parser is right to accept it. But it will show no upcoming runs from most starting points, and the reason is the search window rather than the calendar.

The cron parser walks forward minute by minute with a cap of 500,000 iterations so that a pathological expression cannot hang the tab. That cap is 347.22 days, about 11.4 months. From December 2026 the next 29 February is in 2028, more than fourteen months away, so the projection returns nothing and the tool reports that no matching minute was found within the next eleven months. Measured: from 1 March 2027 it still returns nothing, and from 1 April 2027 it correctly returns 29 February 2028.

The honest reading of an empty result is therefore "nothing inside the window", not "this schedule is broken". For a yearly job such as 0 0 1 1 * the window comfortably contains the next occurrence, so you get one row. For a leap-day job you usually get none. If you need to confirm a rare schedule, reason about the calendar directly or use a scheduler that can project years ahead.

One more calendar edge worth knowing: day-of-month 31 in a month that has 30 days is skipped rather than rolled forward. Cron does not fire on the 1st of the next month as a substitute. If you want "the last day of every month", standard cron has no syntax for it — the usual approach is to run on days 28-31 and have the job check whether tomorrow is the 1st.

Trap Four: The Numbers Are Local to Whatever Runs the Job

A cron expression carries no timezone. 0 9 * * * means nine o'clock in the local time of the machine whose crontab it is. On a laptop that is your own timezone; on a cloud server it is very often UTC, regardless of where you are. A schedule written at 09:00 local and deployed to a UTC server runs at 09:00 UTC, which can be five hours earlier or later than you intended.

This is why a browser-based parser shows times in your timezone while your production job runs in the server's. The two are not disagreeing about the expression; they are evaluating the same sets against different clocks. The parser computes its next-run list only after the page has mounted, precisely so the server-rendered markup and the browser's hydration do not disagree about what "now" is.

The date boundary is where this bites hardest. An instant that is 29 February locally can be 28 February in UTC, and a job scheduled for 00:30 local can land on the previous calendar day in UTC — which changes whether a day-of-month or day-of-week field matches at all. If a schedule involves midnight, a month boundary or a specific weekday, verify it in the timezone the server actually uses. The timestamp converter shows the same instant in both UTC and local time, which is the quickest way to see the shift.

Daylight saving adds two more failures. When clocks spring forward, the skipped hour does not exist, so a job scheduled inside it may not run at all that day. When clocks fall back, the repeated hour happens twice, and a job scheduled inside it may run twice. Neither is a cron bug; both are consequences of describing wall-clock time in a zone that is not monotonic. Scheduling in UTC avoids both entirely, which is the main reason servers default to it.

There is a related boundary trap inside the hour field that has nothing to do with timezones. 9-17 includes the whole of the 17:00 hour, so */15 9-17 * * 1-5 fires at 17:00, 17:15, 17:30 and 17:45. Measured on a Tuesday, the last four runs of the day are 17:15, 17:30, 17:45 and then 09:00 the next morning. "Nine to five" in cron means "up to a quarter to six". To stop at 17:00 exactly, write 0 9-17 * * 1-5 for hourly runs, or */15 9-16 * * 1-5 plus 0 17 * * 1-5.

Reading a Schedule Out of a Config, and a Routine That Catches Everything

Schedules rarely arrive as a bare expression. They arrive inside a YAML pipeline file, a JSON task definition, a Kubernetes CronJob manifest or a database row, usually next to the command they run and the environment they run in. Extracting the expression correctly is half the job, and the surrounding fields are what tell you which timezone and which scheduler dialect you are dealing with. If the config is JSON, the JSON formatter makes the nesting readable; the JSON formatter guide covers the same decode-then-inspect discipline for tokens, timestamps and other dense strings hidden inside payloads.

Know which dialect you are reading before you trust a translation. Quartz and Spring use six or seven fields, starting with seconds, and support ? for "no specific value", L for last, W for nearest weekday and # for the nth weekday of the month. systemd calendar events use a completely different syntax with names like Mon..Fri and *-*-* 09:00:00. Container schedulers such as Kubernetes CronJob use five-field cron but do not accept every token a full cron daemon does, so an expression copied from a Quartz job will not carry across unchanged. None of those extra tokens mean anything to a five-field parser, and the field-count check rejects most of them before the values are even examined.

A routine that catches all four traps takes about a minute. One: count the fields — five, or you are in a different dialect. Two: expand every step and look at the gaps, including the wrap from the last value back to the first; if the step does not divide the field's span, the cadence is uneven. Three: if both day fields are narrowed, remember it is OR, and decide whether that is what you meant. Four: ask whether the date combination exists on a real calendar, and which timezone will evaluate it.

Then confirm against the projected fire times rather than against your reading of the shorthand. The expanded sets and the next-run list are the ground truth; the expression is only a compact way of writing them. When a schedule matters — a billing run, a backup, a data deletion — check the first few projected times in the server's timezone and keep that output with the change. A schedule you have verified once is a schedule you do not have to think about again.

Frequently asked questions

The questions people ask most about cron syntax explained: five fields and traps, answered directly.

What are the five cron fields in order?

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). A useful mnemonic is that the fields go from smallest unit to largest, then jump back to the weekday. There is no seconds field in standard cron; six-field expressions belong to Quartz or Spring.

How do I run a cron job every 15 minutes?

Use */15 in the minute field and stars elsewhere: */15 * * * *. That expands to minutes 0, 15, 30 and 45, so it fires on the quarter hour every hour of every day. Because 15 divides 60 evenly, the gaps are all exactly 15 minutes with no short gap at the hour boundary.

Why does */7 in the hour field not run every seven hours?

Because a step builds a set from the bottom of the field's range and stops at the top. */7 gives hours 0, 7, 14 and 21, so the gaps are 7, 7, 7 and then 3 back to midnight. Seven does not divide 24, so no cron expression can produce a steady seven-hour cadence. Use a divisor of 24, or a scheduler that tracks elapsed time.

What does */25 mean in the minute field?

Minutes 0, 25 and 50. The gaps are 25, 25 and then 10 from :50 back to :00, so the cadence is uneven. This surprises people who read the step as an interval. The same happens with any step that does not divide 60, such as */7, which leaves a four-minute gap at the end of each hour.

Does cron combine day-of-month and day-of-week with AND or OR?

With OR, but only when both fields are restricted. If neither is a star, the job fires when either the day of month or the weekday matches. So 0 0 13 * 5 runs on the 13th and on every Friday. If one of the two fields is a star, only the other test applies, which is the usual way to avoid the ambiguity.

How do I run a job on the 13th only when it is a Friday?

Cron cannot express that intersection. Schedule 0 0 13 * * and have the job check the weekday itself, exiting immediately when it is not Friday. Putting the condition in the job is the standard pattern for any calendar rule the five-field grammar cannot describe, including the last day of the month.

Is 0 or 7 Sunday in cron?

Both. The weekday field accepts 0 through 7 and maps 7 to Sunday, so 0-7 covers the whole week and is equivalent to a star. This also means a range written 1-7 covers Monday through Sunday. Systems that number Sunday as 1 shift every value, so translating between them needs care.

Can I use month or weekday names in a cron expression?

Yes, but only three-letter abbreviations: JAN through DEC and SUN through SAT, case-insensitive. MON-FRI works and is equivalent to 1-5. Full names such as JANUARY or MONDAY are rejected as not being numbers, even though Quartz and some other schedulers accept them.

Why does 0 0 31 4 * parse but never run?

Because each field is validated against its own range, and 31 is a legal day-of-month value while 4 is a legal month. Nothing checks the combination against a real calendar, and April has only 30 days. The same applies to the 31st of June, September and November, and the 30th of February.

Why does a leap-day schedule show no upcoming runs?

Usually because of the search window rather than the calendar. This parser walks forward at most 500,000 minutes, which is 347.22 days or about 11.4 months. From late 2026 the next 29 February is in 2028, beyond that window, so the projection is empty even though the expression is valid. An empty result means nothing inside the window, not a broken schedule.

What timezone does a cron expression use?

The local timezone of the machine running the job. The expression itself carries no timezone information. Most cloud servers run in UTC while your laptop does not, so the same expression fires at different absolute instants. A browser-based parser shows times in your own zone, which is why its output can differ from production.

What happens to cron jobs during daylight saving changes?

In the spring-forward gap the scheduled wall-clock time does not exist, so a job inside it may be skipped. In the fall-back overlap the time occurs twice, so a job inside it may run twice. Scheduling in UTC avoids both, because UTC has no daylight saving and its hours are monotonic.

Does 9-17 in the hour field stop at 17:00?

No. The range includes the entire 17:00 hour, so */15 9-17 * * 1-5 also fires at 17:15, 17:30 and 17:45. To finish at 17:00 exactly, use 0 9-17 for hourly runs, or combine */15 9-16 with 0 17 for quarter-hourly runs that stop on the hour.

What is the difference between 5/10 and 5-55/10?

They expand to the same set, 5, 15, 25, 35, 45 and 55. A step on a lone value is a common extension meaning start here and repeat to the field maximum, but it is not in the original grammar and some daemons reject it. Writing the explicit range is the portable form.

Are @daily and @reboot valid cron expressions?

They are nicknames supported by many cron daemons, not part of the five-field grammar. A strict five-field parser rejects them because they are a single token rather than five fields. @reboot also has no five-field equivalent at all, since it describes an event rather than a wall-clock time.

Why is my six-field cron expression rejected?

Because it is Quartz or Spring syntax, which puts seconds first and may add a year at the end. Standard cron has five fields and no seconds resolution. To convert, drop the seconds field and any trailing year, and replace ? with a star, since standard cron has no no-specific-value token.