DevOps

Cron Expressions for Kubernetes CronJob

Kubernetes CronJob uses standard 5-field cron syntax to schedule batch jobs. Since Kubernetes 1.27, you can specify a timezone with spec.timeZone. CronJobs create Job objects that run to completion.

Format
5-field cron
Fields
5 fields: minute hour day-of-month month day-of-week
Timezone
Cluster timezone (override with spec.timeZone in k8s 1.27+)
Validate your Kubernetes cron expression instantly
Paste any cron expression → get a plain-English explanation, next run times, and lint warnings.

Common Kubernetes Cron Patterns

Every 5 minutes
*/5 * * * *

Runs a job every 5 minutes

Use caseFrequent cache warm-up, fast polling
Every hour
0 * * * *

Runs at the top of every hour

Use caseHourly data aggregation, metrics rollup
Daily database backup
0 2 * * *

Runs at 02:00 every night

Use caseNightly database dump, backup to object storage
Weekly cleanup
0 0 * * 0

Runs every Sunday at midnight

Use caseWeekly log rotation, stale data pruning
Monthly report
0 9 1 * *

Runs at 09:00 on the 1st of every month

Use caseMonthly billing export, SLA reports
Every 6 hours
0 */6 * * *

Runs four times per day

Use casePeriodic cache refresh, data sync
Weekday mornings
30 7 * * 1-5

Runs at 07:30 Monday through Friday

Use casePre-business-hours warm-up, morning digest
End of quarter
0 0 1 1,4,7,10 *

Runs at midnight on January 1, April 1, July 1, October 1

Use caseQuarterly data snapshots, financial reports

Kubernetes CronJob Manifest

yamlKubernetes
apiVersion: batch/v1
kind: CronJob
metadata:
  name: database-backup
  namespace: production
spec:
  # Run every day at 02:00
  schedule: "0 2 * * *"

  # Optional: specify timezone (requires k8s 1.27+)
  timeZone: "America/New_York"

  # Prevent overlapping runs
  concurrencyPolicy: Forbid

  # Allow up to 30s late start before skipping
  startingDeadlineSeconds: 30

  # Keep last 3 successful and 1 failed job
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1

  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: backup
              image: your-backup-image:latest
              command: ["/bin/sh", "-c", "pg_dump $DB_URL > backup.sql"]

How Kubernetes Differs from Standard Crontab

Kubernetes CronJob uses standard 5-field cron syntax identical to crontab. The key addition is spec.timeZone (k8s 1.27+) for explicit timezone control, and CronJob-specific fields like concurrencyPolicy and startingDeadlineSeconds.

Common Gotchas & Pitfalls

1

Timezone defaults to the cluster's system timezone — use spec.timeZone (k8s 1.27+) for explicit control.

2

Set concurrencyPolicy: Forbid if your job must not overlap; Allow is the default.

3

startingDeadlineSeconds defines how late a missed job can start — set it to prevent pile-ups after downtime.

4

CronJob controller checks every 10 seconds, so minimum meaningful interval is around 1 minute.

5

If more than 100 schedules are missed (e.g., cluster was down), Kubernetes will not backfill them.

6

Job pods remain after completion — use successfulJobsHistoryLimit and failedJobsHistoryLimit to control cleanup.

7

Daylight saving time transitions can cause jobs to be skipped or doubled if timezone is set.

Other Platform Guides

More Cron Expression Tools

Translate, build, test, and reference cron expressions — all in one place.