Difference between revisions of "Kubernetes CronJobs"
Jump to navigation
Jump to search
(29 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | Kubernetes <code>CronJob</code>s (previously <code>ScheduledJobs</code>) GA since [[Kubernetes 1.21]] (April 2021) and Beta since [[Kubernetes 1.8]]. | |
− | + | * https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ | |
− | |||
+ | CronJobs are meant for performing regular scheduled actions such as [[backups]], [[report generation]], and so on. Each of those tasks should be configured to recur indefinitely (for example: once a day / week / month); you can define the point in time within that interval when the job should start. | ||
+ | == Example == | ||
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ | https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ | ||
[[apiVersion:]] batch/v1 | [[apiVersion:]] batch/v1 | ||
− | [[kind:]] | + | [[kind: CronJob]] |
− | metadata: | + | [[metadata:]] |
name: hello | name: hello | ||
spec: | spec: | ||
schedule: "*/1 * * * *" | schedule: "*/1 * * * *" | ||
− | jobTemplate: | + | [[jobTemplate:]] |
− | spec: | + | [[spec:]] |
template: | template: | ||
spec: | spec: | ||
containers: | containers: | ||
- name: hello | - name: hello | ||
− | image: [[busybox]] | + | [[image]]: [[busybox]] |
imagePullPolicy: IfNotPresent | imagePullPolicy: IfNotPresent | ||
command: | command: | ||
Line 25: | Line 26: | ||
restartPolicy: OnFailure | restartPolicy: OnFailure | ||
− | + | == Related == | |
− | + | * <code>[[kind: Job]]</code>, <code>[[kubectl get jobs]]</code> | |
− | + | * <code>[[kind: CronJob]]</code>, <code>[[kubectl get cronjob]]</code> | |
+ | * [[Jobs (Kubernetes)]] | ||
+ | * [[Kubernetes scheduling]] | ||
+ | * [[Cronitor]] | ||
== See also == | == See also == | ||
+ | * {{CronJobs}} | ||
+ | * {{Kubernetes Workloads}} | ||
* {{cron}} | * {{cron}} | ||
− | |||
[[Category:K8s]] | [[Category:K8s]] |
Latest revision as of 19:09, 18 November 2023
Kubernetes CronJob
s (previously ScheduledJobs
) GA since Kubernetes 1.21 (April 2021) and Beta since Kubernetes 1.8.
CronJobs are meant for performing regular scheduled actions such as backups, report generation, and so on. Each of those tasks should be configured to recur indefinitely (for example: once a day / week / month); you can define the point in time within that interval when the job should start.
Example[edit]
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
apiVersion: batch/v1 kind: CronJob metadata: name: hello spec: schedule: "*/1 * * * *" jobTemplate: spec: template: spec: containers: - name: hello image: busybox imagePullPolicy: IfNotPresent command: - /bin/sh - -c - date; echo Hello from the Kubernetes cluster restartPolicy: OnFailure
Related[edit]
kind: Job
,kubectl get jobs
kind: CronJob
,kubectl get cronjob
- Jobs (Kubernetes)
- Kubernetes scheduling
- Cronitor
See also[edit]
- CronJobs (Kubernetes), Understand Jobs and CronJobs,
kind: Job
,job-controller
- Kubernetes Workloads:
Deployment
,ReplicaSet, StatefulSet, DaemonSets, Job, CronJob
,.apps/
cron
,crontab
,systemctl list-timers
, anacron, Kubernetes scheduler, Systemd services,CronJobsStack
,cron.schedule
,crontab -l
,0x004b
,at, /etc/cron.deny, /etc/cron.allow, /etc/crontab, /var/spool/cron/crontabs/
Advertising: