NEW
A Kubernetes workload that schedules Jobs to run at specified times or intervals, similar to Unix cron.
DESCRIPTION
Kubernetes CronJob defines time-based schedules to create Job resources that run Pods for tasks like backups, ETL, and periodic processing. It supports cron expressions, history limits, concurrency policies, and starting deadlines. CronJobs leverage Kubernetes controllers and cluster scheduling for reliability and scaling. They are a common choice for batch workloads in cloud-native environments, replacing OS-level cron with cluster-managed execution.
ALTERNATIVE DEFINITIONS
Kubernetes Documentation
A CronJob creates Jobs on a time-based schedule.
Simple emphasis on creating Jobs based on a schedule;
Red Hat OpenShift
CronJobs are used for creating Jobs that run at scheduled times, such as nightly backups.
Highlights common operational use case: scheduled backups.
RELATED TERMS
Kubernetes Job Kubernetes Airflow Scheduler Argo Workflows CI-CD Pods Kubernetes Controller Cluster Autoscaler
COMPETING TERMS
Unix cron Systemd Timers Apache Airflow
KNOWLEDGE AREAS
Infrastructure Software Engineering Data Engineering MLOps
TARGET AUDIENCE
DevOps Engineer Cloud Architect Data Engineer MLOps Engineer Software Developer
EXTERNAL SOURCES
- Wikipedia - Kubernetes
- Kubernetes - Official CronJob concept and API guide.
- Kubernetes - Task tutorial creating CronJobs.
- Red Hat - OpenShift CronJob usage and settings.
TOP QUESTIONS
How do you prevent overlapping runs in a Kubernetes CronJob?
Set concurrencyPolicy to Forbid or Replace to avoid overlapping jobs. Also tune startingDeadlineSeconds and history limits.
Category: Management
What is the difference between a CronJob and a Job in Kubernetes?
A CronJob schedules Jobs at specific times; a Job runs Pods until completion for a one-off task.
Category: Misunderstanding
How reliable is Kubernetes CronJob compared to OS cron?
CronJobs benefit from Kubernetes scheduling, retries, and logging, providing cluster-level reliability and observability versus single-host cron.
Category: Opinion
What are common mistakes with Kubernetes CronJob?
Using wrong cron expressions, ignoring timezone and cluster time, not setting concurrency policies, and missing resource requests/limits are frequent issues.
Category: Mistakes
How to scale CronJob workloads?
Use resource limits, cluster autoscaling, and job parallelism with work queues or shard inputs across multiple Pods.
Category: Example
What is currently a hot topic around Kubernetes CronJob?
Event-driven alternatives using Kubernetes Jobs triggered by pub/sub or webhooks reduce reliance on time-based scheduling.
Category: Topic
How do you monitor CronJobs?
Use Kubernetes events, logs, Prometheus metrics, and alerts for job completions and failures; persist job history.
Category: Observability
What are risks of running sensitive tasks via CronJobs?
Misconfigured RBAC, secrets exposure in Pod specs, and missing TLS for external calls can create security risks.
Category: Risks
Can CronJobs run in multiple namespaces?
Yes, CronJobs are namespaced resources, allowing separate schedules per namespace with independent policies.
Category: Example