I have this cron job running on kubernetes:
# cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: loadjob
spec:
schedule: "05 10 31 Mar *"
successfulJobsHistoryLimit: 3
jobTemplate:
spec:
template:
metadata: # Dictionary
name: apiaplication
labels: # Dictionary
product_id: myprod
annotations:
vault.security.banzaicloud.io/vault-role: #{KUBERNETES_NAMESPACE}#
prometheus.io/path: /metrics
prometheus.io/port: "80"
prometheus.io/scrape: "true"
spec:
containers:
- name: al-onetimejob
image: #{TIMELOAD_IMAGE_TAG}#
imagePullPolicy: Always
restartPolicy: OnFailure
imagePullSecrets:
- name: secret
In the above cron expression I have set it to today morning 10.05AM using cron syntax schedule: 05 10 31 Mar *
- but unfortunately when I checked after 10.05 my job (pod) was not running.
So I found it's not running as expected at 10.05 using the above expression. Can someone please help me to write the correct cron syntax? Any help would be appreciated. Thanks
Cron looks good but checks timezone of your Kubernetes cluster. K8s cluster might be following the UTC timezone and hope you are counting the same in local timezone.
This cron should work : 05 10 31 Mar *
but based on the cluster's date setup.