Cron Atlas

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-2

Message 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.

  1. Rejected0 22-2 * * *beginning of range (22) beyond end of range (2): 22-2
    Use
    0 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.

  2. Rejected0 9 * * FRI-MONbeginning of range (5) beyond end of range (1): FRI-MON
    Use
    0 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

Reference