A CronJob is a Kubernetes object that allows you to run a specific job on a scheduled basis, based on a cron expression. It is useful for tasks like backups, report generation, or other periodic tasks.
xxxxxxxxxx
//Specify cron frequency
//e.g. run minute 0, every hour
0 */1 * * *
//enter a bash command to the script input field
//e.g. a wget command where the output isn't saved
wget -O- url_here >> /dev/null
cron cronjob
xxxxxxxxxx
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
xxxxxxxxxx
apiVersion: batch/v1
kind: CronJob
metadata:
name: busybox-cron
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: busybox
image: busybox:latest
command: ["/bin/sh", "-c”, “echo ‘Hello World’”]
restartPolicy: OnFailure