Kubernetes error TZ= or CRON_TZ= in the schedule
cannot use TZ or CRON_TZ in schedule, use timeZone field instead
spec.schedule: Invalid value: "CRON_TZ=Europe/London 0 9 * * *": cannot use TZ or CRON_TZ in schedule, use timeZone field insteadspec.schedule: Invalid value: "CRON_TZ=Europe/London 0 9 * * *": cannot use both timeZone field and TZ or CRON_TZ in scheduleMessage text from validation.go in Kubernetes’ CronJob validation. Which expressions fail follows the tester’s own engine.
What it means
Kubernetes validation rejects any schedule that contains TZ, which catches both TZ= and CRON_TZ= prefixes, even though the parser underneath understands them. The zone goes in its own field, .spec.timeZone, which takes an IANA name such as Europe/London.
A CronJob that already had a prefix before the check arrived can still be updated while it keeps the prefix. Adding .spec.timeZone to it as well gives the second message.
Rejected expressions and their fixes
Each expression opens in the tester. The message under a rejected one is built the way the source above builds it.
-
RejectedCRON_TZ=Europe/London 0 9 * * *cannot use TZ or CRON_TZ in schedule, use timeZone field instead
09:00 London time every day.
-
RejectedTZ=America/New_York 30 6 * * 1-5cannot use TZ or CRON_TZ in schedule, use timeZone field insteadUse30 6 * * 1-5At 06:30, Monday through Friday (America/New_York).
spec: schedule: "30 6 * * 1-5" timeZone: "America/New_York"06:30 New York time on weekdays.
Questions
- Which Kubernetes version has
.spec.timeZone? - It became stable in Kubernetes 1.27.
- What zone does a CronJob use without
.spec.timeZone? - The local zone of the kube-controller-manager that runs the CronJob controller. Set
.spec.timeZonerather than depend on 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
- 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