Launch offer: 50% off Pro on every one-time tool · ends Oct 25
Cosmovex/tools

Kubernetes CronJob schedule: the cron syntax, timeZone and missed runs

Kubernetes CronJob with Cron Studio

This opens 0 */6 * * *, every six hours, with the Kubernetes tab showing a complete CronJob manifest. Change the schedule and time zone and the YAML follows.

  1. Set the schedule and check the explanation and next runs.
  2. Choose the time zone; Kubernetes 1.27 and later honour spec.timeZone.
  3. Copy the manifest and replace the image and command.
  4. Keep concurrencyPolicy: Forbid unless overlapping runs are safe.
kubernetes cronjob schedule k8s cronjob cron expressioncronjob timezone kuberneteskubernetes cronjob every 6 hourscronjob concurrencyPolicy
Open Cron Studio Free to start · no account

What to know

A CronJob schedule is plain five-field unix cron, evaluated by the controller in the control-plane time zone (usually UTC). Since Kubernetes 1.27 you can set spec.timeZone to an IANA name such as Europe/Berlin; on older clusters, convert the hours to UTC yourself.

Two fields prevent most surprises. concurrencyPolicy: Forbid skips a run if the previous Job is still going (the default Allow starts it anyway), and startingDeadlineSeconds says how late a run may start before it counts as missed. If a CronJob misses more than 100 schedules in a row it stops being scheduled until you fix it.

A CronJob that "does nothing" is hard to notice. Add a Cronwatch ping to the end of the container command so you hear about a silent failure the same day instead of when the data is already stale. A CronJob that completes with exit code 0 but did no useful work is the case that logs alone never reveal.

Updated · Cosmovex

Questions

What cron syntax does Kubernetes use?

Standard five-field cron: minute, hour, day of month, month, day of week. It also accepts @hourly, @daily, @weekly, @monthly and @yearly.

How do I set a time zone on a Kubernetes CronJob?

Set spec.timeZone to an IANA name such as America/New_York. It is stable from Kubernetes 1.27; before that, schedules run in the controller time zone.

Why did my CronJob stop running?

If more than 100 scheduled runs are missed (for example because the cluster was down or startingDeadlineSeconds is too short) the controller stops scheduling and logs an error. Check kubectl describe cronjob.

How do I stop two Jobs running at once?

Set concurrencyPolicy: Forbid to skip a run while the previous Job is active, or Replace to cancel the old one.

The free plan covers everything on this page. Cron Studio Pro ($19, paid once) is described on the Cron Studio page.