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): 7spec.schedule: Invalid value: "0 24 * * *": end of range (24) above maximum (23): 24Message 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.
-
Use0 0 * * 0At 00:00, on Sundays.
Midnight on Sundays.
SUNworks too. -
Use0 9 * * *At 09:00.
Every day at 09:00. Monday to Sunday is all seven days.
-
Use0 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.
-
Use0 0 * * *At 00:00.
Midnight every day.
Questions
- Is Sunday 0 or 7 in a Kubernetes CronJob?
- Sunday is 0, and 7 is rejected.
SUNalso works and reads more clearly. - Why does
0 9 * * 1-7work 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
- expected exactly 5 fields, found 6: [0 0 12 * * ?]Kubernetes: Six or seven fields
- beginning of range (0) below minimum (1): 0Kubernetes: Day or month written as 0
- beginning of range (22) beyond end of range (2): 22-2Kubernetes: A range that wraps around
- 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