Skip to main content
K8sCalc

kubernetes

Kubernetes CronJob Generator

Generate a Kubernetes CronJob YAML for scheduled tasks — database backups, report generation, cache warming, or any periodic job.

Kubernetes CronJobs

CronJobs use standard Unix cron syntax to schedule Pods at regular intervals.

Cron Schedule Syntax

┌──────── minute (0–59)
│  ┌───── hour (0–23)
│  │  ┌── day of month (1–31)
│  │  │  ┌─ month (1–12)
│  │  │  │  ┌ day of week (0–6, Sun=0)
│  │  │  │  │
*  *  *  *  *

Common Schedules

ScheduleMeaning
0 2 * * *Daily at 2:00 AM
0 * * * *Every hour
*/15 * * * *Every 15 minutes
0 2 * * 0Weekly, Sunday at 2 AM
0 2 1 * *Monthly, 1st at 2 AM

Manually Trigger a CronJob

bash
kubectl create job --from=cronjob/my-cronjob manual-run-$(date +%s) -n default

Suspend a CronJob Temporarily

bash
kubectl patch cronjob my-cronjob -p '{"spec": {"suspend": true}}'
# Resume:
kubectl patch cronjob my-cronjob -p '{"spec": {"suspend": false}}'

Frequently Asked Questions

What does the concurrency policy do?

It controls what happens if a CronJob is still running when the next scheduled run is due. Forbid (recommended) skips the new run — safe for backup jobs where overlapping runs would cause conflicts. Allow lets runs overlap — fine for idempotent jobs. Replace cancels the current run and starts a fresh one — use for jobs where only the latest result matters.

What is the difference between a CronJob and a Job?

A Job runs once and completes. A CronJob is a controller that creates a new Job on a schedule — essentially a cron daemon for Kubernetes. When a CronJob fires, it creates a Job object, which in turn creates a Pod. You can manually trigger a CronJob with: kubectl create job --from=cronjob/<name> <manual-name>.

How do I debug a failed CronJob?

Check the Job and Pod history: kubectl get jobs -n <namespace> — this shows recent runs. kubectl describe job <job-name> — shows pod status. kubectl logs <pod-name> — shows job output. Note: with failedJobsHistoryLimit: 1 (the default), you only keep 1 failed pod for inspection. Increase it during debugging.

CronJob isn't running at the expected time — why?

CronJob times are in the cluster's timezone (usually UTC). If your schedule is 0 2 * * * expecting 2am local time but the cluster is UTC, adjust for the offset. Also check: kubectl get cronjob <name> — the 'LAST SCHEDULE' and 'ACTIVE' columns. If LAST SCHEDULE shows 'never', the CronJob hasn't fired yet or the controller is behind. Missed schedules more than startingDeadlineSeconds ago are skipped.

Related Guides