Kubernetes error Day or month written as 0
beginning of range (0) below minimum (1): 0
spec.schedule: Invalid value: "0 0 0 * *": beginning of range (0) below minimum (1): 0Message produced by running the expression through robfig/cron v3.0.1, the parser and version Kubernetes validates .spec.schedule with.
What it means
Days of the month and months are numbered from 1. A 0 in either field is below the minimum. The message doesn’t name the field, so look for a 0 in the third or fourth position, including at the start of a step like 0/2.
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 1 * *At 00:00, on the 1st of the month.
Midnight on the 1st of the month.
-
Use0 0 1 1 *At 00:00, on the 1st of the month, in January.
Midnight on 1 January.
JANworks too. -
Use0 0 */2 * *At 00:00, every 2 days of the month, from the 1st.
Every other day of the month: the 1st, 3rd, 5th and so on.
Questions
- Why is 0 allowed in the hour but not the day?
- Minutes and hours count from zero, but days of the month and months are numbered from 1. Day of week also starts at 0, for Sunday.
- Does
*/2in day of month mean every 48 hours? - No. It matches the odd-numbered days, so a 31-day month runs on the 31st and again on the 1st.
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 (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