Cron Atlas

Kubernetes error Sunday written as 7

end of range (7) above maximum (6): 7

spec.schedule: Invalid value: "0 0 * * 7": end of range (7) above maximum (6): 7
spec.schedule: Invalid value: "0 24 * * *": end of range (24) above maximum (23): 24

Message produced by running the expression through robfig/cron v3.0.1, the parser and version Kubernetes validates .spec.schedule with.

What it means

Each field has a maximum: 59 for minutes, 23 for hours, 31 for day of month, 12 for months and 6 for day of week. The message gives the value that went over, then the maximum, then the item it was found in.

Day of week is the usual culprit. Many Unix crons accept both 0 and 7 for Sunday, but the parser behind Kubernetes stops at 6 (Saturday), so Sunday must be 0 or SUN. Hours stop at 23: midnight is 0.

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 0 * * 7end of range (7) above maximum (6): 7
    Use
    0 0 * * 0At 00:00, on Sundays.

    Midnight on Sundays. SUN works too.

  2. Rejected0 9 * * 1-7end of range (7) above maximum (6): 1-7
    Use
    0 9 * * *At 09:00.

    Every day at 09:00. Monday to Sunday is all seven days.

  3. Rejected0 9 * * 5-7end of range (7) above maximum (6): 5-7
    Use
    0 9 * * 0,5,6At 09:00, on Sundays and Fridays and Saturdays.

    Friday to Sunday. A range can’t run past Saturday, so list the days.

  4. Rejected0 24 * * *end of range (24) above maximum (23): 24
    Use
    0 0 * * *At 00:00.

    Midnight every day.

Questions

Is Sunday 0 or 7 in a Kubernetes CronJob?
Sunday is 0, and 7 is rejected. SUN also works and reads more clearly.
Why does 0 9 * * 1-7 work in my crontab but not in Kubernetes?
Vixie cron and cronie accept 7 as Sunday. robfig/cron, which Kubernetes validates schedules with, does not.

Other Kubernetes errors

Reference