Kubernetes CronJob Schedule Generator
Generate cron expressions for Kubernetes CronJob spec.schedule fields. Build and validate schedules for nightly backups, batch jobs, and periodic tasks in K8s.
Cron Expressions for Kubernetes CronJobs
Kubernetes CronJobs use standard 5-field cron syntax in the spec.schedule field. The expression controls when the Job is triggered โ the same syntax used in Linux cron, but evaluated by the Kubernetes control plane. Getting the schedule wrong means jobs run at the wrong time or not at all โ verify expressions before deploying.
- 5-field format:
minute hour day-of-month month day-of-weekโ same as standard cron - Time zone: CronJob runs in UTC by default;
spec.timeZonefield available in Kubernetes 1.27+ - Minimum interval: Kubernetes recommends no more frequent than once per minute
- Build expressions: Use the cron generator to build and validate your schedule before pasting into the manifest
- Common schedules: Nightly backup:
0 2 * * *| Hourly:0 * * * *| Weekday morning:0 9 * * 1-5
Choose the Right Variant
- This page: Kubernetes CronJob schedules โ spec.schedule field expressions
- Cron Expression Generator: Build and validate any cron schedule
- GitHub Actions Schedule: on:schedule cron expressions for GitHub Actions
- Cron Job Examples: Common cron expression reference
Kubernetes CronJob Manifest Example
- Basic structure: The
spec.schedulefield takes a quoted cron string:schedule: "0 2 * * *" - Time zone (K8s 1.27+): Add
spec.timeZone: "America/New_York"to run in local time instead of UTC - Concurrency policy:
spec.concurrencyPolicy: Forbidprevents overlapping runs โ important for long-running jobs - Failed job history:
spec.failedJobsHistoryLimit: 3โ keep last 3 failed jobs for debugging - Missed schedules:
spec.startingDeadlineSecondsโ how late a missed job can start before being skipped
Common Kubernetes CronJob Schedules
- Nightly database backup:
0 2 * * *(2:00 AM UTC daily) - Hourly data sync:
0 * * * * - Every 15 minutes:
*/15 * * * * - Weekday report generation:
0 7 * * 1-5(7:00 AM MonโFri UTC) - Weekly cleanup:
0 3 * * 0(3:00 AM Sunday UTC) - First of month billing:
0 0 1 * *
Privacy and Data Handling
All cron expression generation and validation runs locally in your browser. No data is sent to any server.
Frequently Asked Questions
Does Kubernetes support seconds in cron expressions?
No. Standard Kubernetes CronJobs use 5-field cron syntax (minute through day-of-week) โ no seconds field. The minimum granularity is one minute. If you need sub-minute scheduling, use a different mechanism: a long-running Deployment with an internal sleep loop, or a message queue consumer. Some third-party Kubernetes operators extend CronJob with seconds support, but the native resource does not support it.
How do I set a specific timezone for a Kubernetes CronJob?
Add spec.timeZone: "America/New_York" to your CronJob spec โ available in Kubernetes 1.27+ (graduated to stable in 1.29). Use IANA timezone names (e.g., "Europe/London", "Asia/Tokyo", "America/Los_Angeles"). In older clusters, the only option is to convert your desired local time to UTC and set that in the schedule. Verify your cluster version with kubectl version before using spec.timeZone.
What happens if a Kubernetes CronJob misses its scheduled time?
If the Kubernetes control plane is down or the CronJob is suspended at the scheduled time, the job is "missed." Kubernetes tracks missed schedules and uses spec.startingDeadlineSeconds to determine if a missed job should still run when the cluster recovers. If more than 100 schedules are missed (e.g., the cluster was down for a long period), Kubernetes may stop scheduling the job entirely and log an error โ monitor for this in production. Set startingDeadlineSeconds to a reasonable window (e.g., 3600 for hourly jobs) to control this behavior.