Key Concepts
CronJob
A resource that creates Jobs on a recurring schedule defined by cron syntax.
Schedule
Cron expression defining when Jobs should be created (e.g.,
0 * * * * for hourly).Job
A single execution instance created by the CronJob at each scheduled time.
Suspend
Temporarily stop scheduling new Jobs without deleting the CronJob.
Required Permissions
| Action | Permission |
|---|---|
| View cronjobs | iam:project:infrastructure:kubernetes:read |
| Run now (trigger) | iam:project:infrastructure:kubernetes:write |
| Suspend/Resume | iam:project:infrastructure:kubernetes:write |
| Create cronjob | iam:project:infrastructure:kubernetes:write |
| Edit cronjob | iam:project:infrastructure:kubernetes:write |
| Delete cronjob | iam:project:infrastructure:kubernetes:delete |
CronJob Status Values
| Status | Description |
|---|---|
| Active | CronJob is enabled and will create Jobs on schedule |
| Suspended | CronJob is paused and will not create new Jobs |
Cron Schedule Format
CronJobs use standard cron syntax with five fields:| Schedule | Cron Expression |
|---|---|
| Every minute | * * * * * |
| Every hour | 0 * * * * |
| Every day at midnight | 0 0 * * * |
| Every Monday at 9am | 0 9 * * 1 |
| Every 15 minutes | */15 * * * * |
| Weekdays at 6am | 0 6 * * 1-5 |
| Shorthand | Equivalent |
|---|---|
@hourly | 0 * * * * |
@daily | 0 0 * * * |
@weekly | 0 0 * * 0 |
@monthly | 0 0 1 * * |
@yearly | 0 0 1 1 * |
How to View CronJobs
How to View CronJob Details
How to Run a CronJob Immediately
Trigger a CronJob to run now without waiting for the next scheduled time.Manually triggered Jobs have the label
triggered-by: manual to distinguish them from scheduled Jobs.How to Suspend a CronJob
Suspend a CronJob to temporarily stop scheduling new Jobs.How to Resume a CronJob
Resume a suspended CronJob to restart scheduling.How to Create a CronJob
Write YAML
Enter the CronJob manifest in YAML format. Key fields:
spec.schedule- Cron expressionspec.jobTemplate- Job template specificationspec.concurrencyPolicy- How to handle concurrent Jobs
How to Edit a CronJob
Modify Spec
Edit the CronJob specification. Common changes:
- Schedule expression
- Container image or command
- Concurrency policy
- History limits
How to Delete a CronJob
Concurrency Policies
Control what happens when a new Job is scheduled while a previous Job is still running:| Policy | Description |
|---|---|
| Allow | Allow concurrent Jobs (default) |
| Forbid | Skip new Job if previous is still running |
| Replace | Cancel running Job and start new one |
History Limits
CronJobs track completed and failed Jobs for review:| Setting | Description | Default |
|---|---|---|
successfulJobsHistoryLimit | Number of successful Jobs to keep | 3 |
failedJobsHistoryLimit | Number of failed Jobs to keep | 1 |
Troubleshooting
CronJob not creating Jobs
CronJob not creating Jobs
- Check if CronJob is suspended
- Verify schedule syntax is correct
- Check concurrency policy - previous Job may still be running
- Review CronJob events for errors
- Verify time zone considerations
Jobs failing immediately
Jobs failing immediately
- Check container image exists and is accessible
- Verify command and arguments are correct
- Check required ConfigMaps/Secrets exist
- Review Job pod logs for error messages
Missed schedules
Missed schedules
- If more than 100 schedules are missed, CronJob stops
- Check
startingDeadlineSecondssetting - Verify cluster has available resources
- Review CronJob events
Jobs running longer than expected
Jobs running longer than expected
- Set
activeDeadlineSecondson Job template to limit runtime - Consider using Forbid concurrency policy
- Check for resource constraints slowing execution
Too many Jobs accumulating
Too many Jobs accumulating
- Reduce
successfulJobsHistoryLimitandfailedJobsHistoryLimit - Jobs beyond limits are automatically cleaned up
- Manually delete old Jobs if needed
Manual trigger not working
Manual trigger not working
- Verify you have write permission
- Check cluster connectivity
- Review Job creation errors in events
FAQ
What time zone does the schedule use?
What time zone does the schedule use?
CronJobs use the kube-controller-manager’s time zone by default, which is typically UTC. Kubernetes 1.27+ supports the
timeZone field to specify a different zone.Can I run a CronJob manually for testing?
Can I run a CronJob manually for testing?
Yes. Use the Run Now action to trigger immediate execution. The created Job will have
triggered-by: manual label.What happens to running Jobs when I delete a CronJob?
What happens to running Jobs when I delete a CronJob?
Running Jobs continue to completion. Only future scheduled Jobs are prevented. Delete Jobs separately if needed.
How do I see output from a CronJob?
How do I see output from a CronJob?
View the logs of pods created by the Job. Navigate to Jobs page, find the Job, and view pod logs.
Can I change the schedule without recreating?
Can I change the schedule without recreating?
Yes. Edit the CronJob YAML and update the
spec.schedule field. Changes apply to future schedules.What's the difference between Forbid and Replace concurrency?
What's the difference between Forbid and Replace concurrency?
Forbid skips the new Job entirely if one is running. Replace cancels the running Job and starts a new one. Use Forbid for jobs that must complete; use Replace for jobs where only the latest run matters.
How do I prevent Jobs from running too long?
How do I prevent Jobs from running too long?
Set
spec.jobTemplate.spec.activeDeadlineSeconds to limit Job runtime. The Job will be terminated if it exceeds this duration.Can CronJobs restart failed Jobs?
Can CronJobs restart failed Jobs?
CronJobs don’t retry failed Jobs. Use Job’s
backoffLimit to retry within a single Job, or let the next scheduled run attempt the task.