Kubernetes error A range that wraps around
beginning of range (22) beyond end of range (2): 22-2
spec.schedule: Invalid value: "0 22-2 * * *": beginning of range (22) beyond end of range (2): 22-2Message produced by running the expression through robfig/cron v3.0.1, the parser and version Kubernetes validates .spec.schedule with.
What it means
Ranges in a Kubernetes schedule have to run upwards. An overnight window like 22-2 or a long weekend like FRI-MON wraps past the end of the field, and the parser won’t wrap. Split it into two ranges in a list.
Rejected expressions and their fixes
Each expression opens in the tester. The message under a rejected one is what robfig/cron v3.0.1 printed for it.
-
Use0 22-23,0-2 * * *At 00:00, 01:00, 02:00, 22:00 and 23:00.
On the hour from 22:00 to 02:00. Each field is matched on its own, so this is the late and the early hours of every day.
-
Use0 9 * * 0-1,5-6At 09:00, on Sundays and Mondays and Fridays and Saturdays.
Friday to Monday at 09:00.
Questions
- Do other dialects allow
22-2? - Quartz and EventBridge read a reversed range as wrapping around. Standard cron and Kubernetes reject it, Azure swaps the two ends, and GitHub doesn’t document it.
Other Kubernetes errors
- expected exactly 5 fields, found 6: [0 0 12 * * ?]Kubernetes: Six or seven fields
- end of range (7) above maximum (6): 7Kubernetes: Sunday written as 7
- beginning of range (0) below minimum (1): 0Kubernetes: Day or month written as 0
- failed to parse int from L: strconv.Atoi: parsing "L": invalid syntaxKubernetes:
L,#,WorH - cannot use TZ or CRON_TZ in schedule, use timeZone field insteadKubernetes:
TZ=orCRON_TZ=in the schedule