apiVersion: batch/v1
kind: CronJob
metadata:
name: devops
spec:
schedule: "*/9 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: cron-devops
image: nginx:latest
command:
- /bin/sh
- -c
- echo Welcome to xfusioncorp!
restartPolicy: OnFailureApply the CronJob
kubectl apply -f cronjob.yamlVerify the CronJob
kubectl get cronjob devopsCheck jobs created by the CronJob
kubectl get jobsView CronJob details
kubectl describe cronjob devopsCron Schedule Reference #
| Field | Values | Description |
|---|---|---|
| Minute | 0-59 | Minute of the hour |
| Hour | 0-23 | Hour of the day |
| Day of Month | 1-31 | Day of the month |
| Month | 1-12 | Month of the year |
| Day of Week | 0-6 | Day of the week (0 = Sunday) |
Common examples:
*/5 * * * *— Every 5 minutes0 * * * *— Every hour0 0 * * *— Daily at midnight0 0 * * 0— Weekly on Sunday at midnight