Skip to content
cronhelp.me
Guide · Foot-guns

Range that wraps past the end of the field

Short answer
A range like 22-2 reads backwards. Some cron implementations wrap it around midnight, others reject it or read only part — it is a portability hazard.
Wrong"from 10 PM to 2 AM"
0 22-2 * * *
Rightlist the hours explicitly so every cron agrees
0 22,23,0,1,2 * * *

A range is written low-to-high: 9-17 means 9 through 17. When the start is greater than the end — 22-2 in hours, or FRI-MON in the day-of-week field — the range runs "backwards" past the end of the field, and cron implementations disagree about what to do with it.

Some, following the classic Vixie cron behaviour, reject the entry or interpret it in a way you did not expect. Others wrap it around the field boundary, so 22-2 becomes 22, 23, 0, 1, 2 — the hours from 10 PM through 2 AM across midnight. Because the behaviour is not standardised, the same expression can run differently on two systems, which makes wrapped ranges a genuine portability hazard even when they happen to work where you first tested them.

This tool resolves a wrapped range by expanding it around the boundary, so you can see the intended firing values, but it warns because you should not rely on every scheduler agreeing. The safest fix is to make the intent explicit with a list. For "10 PM to 2 AM", write 0 22,23,0,1,2 * * * — every cron reads a comma list identically, with no wrap-around ambiguity. For a weekend-spanning weekday range like Friday to Monday, list the days: * * * * 5,6,0,1.

If your schedule really does need to span midnight and you want to keep it compact, at least confirm your specific scheduler's documented behaviour and leave a comment, because the next person to read it — or the next platform you deploy to — may interpret the wrap differently. When in doubt, spell it out.

Watch the linter flag it live — the finding below appears the moment the expression is entered:

Cron expression5-field
Every hour, between 10:00 PM and 02:00 AM
Lint
Warningrange-wrap
Cron programs disagree about what '22-2' means, because it runs backwards — from 22 to 2: some reject the entry, some run it on the wrong days, and some wrap around the way you probably intended. Spell it out instead: '22-23,0-2'.
Learn more →
Next runs
#
1
2
3
4
5
6
7
Copy as
All lint rulesSeverity: Warning