简体   繁体   English

Kubernetes CronJob 多个计划时间

[英]Kubernetes CronJob multiple schedule times

I want to run one cron at different times.我想在不同的时间运行一个 cron。

Is it possible to do something like this in my YML file:是否可以在我的 YML 文件中执行类似的操作:

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?还是我必须为每个计划时间创建单独的 YML 文件?

The short answer is: no, you cannot create one CronJob YML with several crontab times schedules.简短的回答是:不,您不能创建一个具有多个 crontab 时间计划的CronJob YML。

The easy solution would be to use separate CronJob resource for each crontab line from your example.简单的解决方案是为示例中的每个 crontab 行使用单独的CronJob资源。 You can use the same image for each of your CronJobs .您可以为每个CronJobs使用相同的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM