Kubernetes CronJob multiple schedule times

Viewed 2829

I want to run one cron at different times.

Is it possible to do something like this in my YML file:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my-cronjob
spec:
  schedule: 
    - "*/10 00-08 * * *"
    - "*/5 09-18 * * *"
    - "*/10 19-23 * * *"
  concurrencyPolicy: Forbid
...

or do I have to create separate YML files for every schedule time?

1 Answers

The short answer is: no, you cannot create one CronJob YML with several crontab times schedules.

The easy solution would be to use separate CronJob resource for each crontab line from your example. You can use the same image for each of your CronJobs.

Related