> Markdown version of https://opspane.dev/cron/kubernetes/ for AI agents and readers: the same text, without navigation or the interactive tool.
>
> The tool computes its result with JavaScript in the browser, so this file holds the reference text, worked examples and FAQ. Open the page to run it on your own input.
>
> Answer endpoint for agents: the same URL parameters on https://opspane.dev/cron/kubernetes/answer.md return the computed result as Markdown, without JavaScript, e.g. https://opspane.dev/cron/kubernetes/answer.md?expr=0%203%20*%20*%20*&tz=Europe%2FBerlin

# Kubernetes CronJob Generator

Generate a complete CronJob manifest with schedule, timeZone, concurrencyPolicy and history limits, explained field by field.

## Quick answer

- `spec.schedule` takes five cron fields, minute first with no seconds, or a macro from `@hourly` to `@every 1h30m`; robfig/cron parses it.
- `7` for Sunday is rejected: use `0` or `SUN`.
- `spec.timeZone` takes an IANA name (stable since 1.27); without it the schedule follows kube-controller-manager's zone, and `TZ=` or `CRON_TZ=` inside the schedule is rejected.
- `concurrencyPolicy`: `Allow` (the default) runs overlapping Jobs side by side, `Forbid` skips the new run, `Replace` stops the running Job and starts the new one.

## How to use

1. Type the schedule in `spec.schedule` syntax and pick the time zone for `spec.timeZone`.
2. Fill in the name, image and command, and choose what happens when runs overlap.
3. Copy the manifest, save it as `cronjob.yaml` and run `kubectl apply -f` on it.

## CronJob fields explained

| Field | What it does |
| --- | --- |
| `schedule` | Five cron fields (or a macro) parsed by robfig/cron. |
| `timeZone` | IANA zone for the schedule; stable since 1.27. Default: the controller's zone. |
| `concurrencyPolicy` | `Allow`, `Forbid` or `Replace` when a run is due while the last one is still running. |
| `startingDeadlineSeconds` | Deadline for starting a missed run; empty means no deadline. |
| `successfulJobsHistoryLimit` | Finished Jobs to keep (default 3). |
| `failedJobsHistoryLimit` | Failed Jobs to keep (default 1). |
| `suspend` | Pauses new runs; already-running Jobs continue. |
| `restartPolicy` | `OnFailure` retries inside the pod; `Never` creates a new pod per retry. |

## When a run is still going: concurrencyPolicy

When the next run comes due while the previous one is still running, what happens is decided by `concurrencyPolicy`: `Allow` (the default) runs them side by side, `Forbid` skips the run that came due, and `Replace` stops the running job first and starts the new one in its place.

`*/10 * * * *` job takes 20 min · window 10:00–10:20

A 20-minute job due again after 10 minutes: **Allow** starts job #2 alongside job #1, while **Forbid** skips the run that came due at 10:10 and **Replace** stops job #1 first, starting job #2 in its place.

## Schedule syntax in Kubernetes

The CronJob controller parses `spec.schedule` with the Go library robfig/cron. It takes the usual five fields plus `@hourly`, `@daily`, `@weekly`, `@monthly`, `@yearly` and `@every 1h30m`. Unlike Linux crontab it rejects `7` for Sunday.

### Both day fields are set: AND or OR

`*/2` in a day field is a restriction rather than a full wildcard, so `0 0 */2 * 1` runs on odd days _or_ Mondays under robfig/cron, while Linux crontab requires **both** to match — only the 9th and 23rd of March 2026 are odd days that are also Mondays. The [Cron Expression Explainer](https://opspane.dev/cron/explainer/) shows both readings side by side.

`0 0 */2 * 1` day-of-month */2 and day-of-week 1 · March 2026

Same schedule, two readings. Crontab requires **both** day fields to match: only the 9th and 23rd of March 2026 are odd days that are also Mondays. Kubernetes (robfig/cron) treats `*/2` as a restriction too and runs when **either** matches — 19 runs.

## Time zones and daylight saving

Set `spec.timeZone` to an IANA name; the tool previews the runs in that zone. Like crontab, robfig/cron skips a time that does not exist when clocks spring forward and runs a repeated time twice when they fall back. In zones with a 30-minute daylight-saving change (Lord Howe Island) it can also skip a run on the change day — the warnings show exactly which.

## How the results are verified

Schedules and next runs are checked against robfig/cron v3.0.1, the library the CronJob controller uses, on 316 expression, time-zone and start-time combinations. Field rules and limits follow the Kubernetes CronJob documentation.

## FAQ

### How do I set a time zone for a Kubernetes CronJob?

Set spec.timeZone to an IANA name such as Europe/Berlin or Etc/UTC; the field is stable since Kubernetes 1.27. Without it, the schedule follows the time zone of kube-controller-manager. TZ= or CRON_TZ= inside spec.schedule is rejected.

### What does concurrencyPolicy do?

It decides what happens when a run is due while the previous Job is still running: Allow starts another one, Forbid skips the new run, Replace stops the running Job and starts the new one.

### What is startingDeadlineSeconds?

How many seconds late a missed run may still start, for example after the controller was down. Leave it empty for no limit. Values under 10 can stop the Job from ever being scheduled, because the controller checks every 10 seconds.

### Is Sunday 0 or 7 in a CronJob schedule?

Kubernetes parses schedules with the Go library robfig/cron, which accepts 0–6 (or SUN–SAT) and rejects 7. Use 0 or SUN for Sunday.

### How long can a CronJob name be?

At most 52 characters: the controller appends 11 characters to name each Job, and Job names are limited to 63. Use lowercase letters, digits and hyphens.

### Why does my CronJob say it missed too many start times?

If the controller finds more than 100 missed schedules since the last run, it does not start the Job and logs an error. Setting startingDeadlineSeconds limits how far back it counts.

## Related tools

- [systemd OnCalendar](https://opspane.dev/cron/systemd/): Test systemd OnCalendar expressions, convert between cron and systemd timers, and generate ready-to-use .timer and .service files.
- [Cron Expression Converter](https://opspane.dev/cron/translate/): Convert one schedule to crontab, Quartz, AWS EventBridge, GitHub Actions, Kubernetes and systemd — with next run times for each.
- [Kubernetes Secret Decoder](https://opspane.dev/kubernetes/secret-decoder/): Decode every value in a Kubernetes Secret from pasted YAML and encode data back into a manifest. Nothing leaves your browser.
- [Kubernetes QoS Class & Requests Checker](https://opspane.dev/kubernetes/requests-limits/): Paste a Pod or Deployment: get its QoS class and why, the Pod request with init and sidecar containers, oom_score_adj and how many Pods fit a node.
