The schedule field
spec.schedule takes a five-field cron expression, for example "0 */6 * * *" for every six hours. Kubernetes also accepts macros such as @hourly, @daily, @weekly, @monthly and @yearly. Quote the value in YAML so the asterisks are not misread.
Time zones with spec.timeZone
Without a time zone, schedules are interpreted in the time zone of the kube-controller-manager, which is usually UTC. Since Kubernetes 1.27 you can set spec.timeZone to an IANA name such as Europe/Berlin. Select the same zone in the tool to preview the exact creation times, including daylight-saving transitions.
Missed runs and concurrency
If the controller misses a scheduled time, startingDeadlineSeconds decides how late a Job may still start. concurrencyPolicy controls what happens when a run is still active: Allow, Forbid or Replace. Keep those settings in mind when you choose frequent schedules such as every minute.
Use kubectl create job --from=cronjob/<name> <job-name> to start a run immediately while testing, and kubectl get cronjob to check the LAST SCHEDULE and ACTIVE columns. Events on the CronJob object explain why a scheduled time was skipped or why a Job failed to start.
A minimal manifest
A CronJob uses apiVersion batch/v1 and kind CronJob, with spec.schedule, an optional spec.timeZone and a jobTemplate that describes the Pod to run. Set suspend: true to pause the schedule without deleting it, and successfulJobsHistoryLimit and failedJobsHistoryLimit to control how many finished Jobs are kept for debugging.
Frequently asked questions
- Does a Kubernetes CronJob support seconds?
- No. The schedule has five fields, so the smallest interval is one minute.
- Can I use CRON_TZ in the schedule?
- No. TZ and CRON_TZ prefixes are not supported; use the spec.timeZone field instead.
- What does 0 */6 * * * mean?
- Every six hours on the hour: 00:00, 06:00, 12:00 and 18:00.
- Why did my CronJob run twice or not at all?
- Check startingDeadlineSeconds and concurrencyPolicy, and whether the controller was down. CronJobs aim for roughly one Job per scheduled time but don’t guarantee it.