Skip to main content
Course/Primitives/CronJobs β€” Scheduled Work
6/845 min
Primitives

CronJobs β€” Scheduled Work

Run Jobs on a time schedule using standard cron syntax. Essential for backups, cleanups, and reports.

beginner45 minRead β†’ Lab β†’ Quiz β†’ Practice
🧠 Brain Warm-Up
🧠 Brain Warm-Up: If your backup CronJob runs every hour but takes 90 minutes to complete, what happens at the next scheduled run? Should the old job be killed? Allowed to run in parallel? Think about concurrencyPolicy before reading.

CronJob β†’ Job β†’ Pod

CronJobs create Jobs on a schedule. Jobs run Pods to completion.

CronJob (schedule: "0 * * * *")
 └── Job nginx-backup-1730000000  (created each hour)
      └── Pod nginx-backup-1730000000-abc12  (runs task, exits 0)

Cron Schedule Syntax

β”Œβ”€β”€β”€ minute (0-59)
β”‚ β”Œβ”€β”€β”€ hour (0-23)
β”‚ β”‚ β”Œβ”€β”€β”€ day of month (1-31)
β”‚ β”‚ β”‚ β”Œβ”€β”€β”€ month (1-12)
β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€ day of week (0-6, Sun=0)
β”‚ β”‚ β”‚ β”‚ β”‚
* * * * *

Examples:
"0 * * * *"    every hour at :00
"*/5 * * * *"  every 5 minutes
"0 2 * * *"    every day at 02:00
"0 0 * * 0"    every Sunday at midnight

Key Fields

FieldDefaultMeaning
concurrencyPolicyAllowAllow/Forbid/Replace concurrent runs
successfulJobsHistoryLimit3Keep N completed jobs
failedJobsHistoryLimit1Keep N failed jobs
startingDeadlineSecondsnilMiss window β†’ skip
suspendfalsePause scheduling

concurrencyPolicy

  • Allow: new job starts even if previous still running
  • Forbid: skip new run if previous still running
  • Replace: kill previous run, start new one