35-cronJob

concepts/workloads/controllers/cron-jobs/

CronJob

A Cron Job creates Jobs on a time-based schedule. cron job按基于时间的计划创建作业

One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format. 一个cronjob对象就像crontab(cron table)文件的一行。它按照给定的时间表定期运行作业,以cron格式编写

Note: All CronJob schedule: times are based on the timezone of the master where the job is initiated.

For instructions on creating and working with cron jobs, and for an example of a spec file for a cron job, see Running automated tasks with cron jobs. 有关创建和使用cron作业的说明,以及cron作业的spec文件示例,请参见

Cron Job Limitations

A cron job creates a job object about once per execution time of its schedule. We say “about” because there are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare, but do not completely prevent them. Therefore, jobs should be idempotent. cron作业在其计划的每个执行时间创建一个作业对象大约一次。我们之所以说“关于”,是因为在某些情况下,可能会创造两个工作岗位,也可能不会创造任何工作岗位。我们试图使这些罕见,但并不完全阻止他们。因此,作业应该是等幂

If startingDeadlineSeconds is set to a large value or left unset (the default) and if concurrencyPolicy is set to Allow, the jobs will always run at least once. 如果“startingdeadlineseconds”设置为大值或未设置(默认值),并且“concurrency policy”设置为“allow”,则作业将始终至少运行一次。

For every CronJob, the CronJob Controller checks how many schedules it missed in the duration from its last scheduled time until now. If there are more than 100 missed schedules, then it does not start the job and logs the error 对于每个cronjob,cronjob控制器检查从上次计划时间到现在的持续时间内它错过了多少计划。如果错过的计划超过100个,则它不会启动作业并记录错误

Cannot determine if job needs to be started. Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.

It is important to note that if the startingDeadlineSeconds field is set (not nil), the controller counts how many missed jobs occurred from the value of startingDeadlineSeconds until now rather than from the last scheduled time until now. For example, if startingDeadlineSeconds is 200, the controller counts how many missed jobs occurred in the last 200 seconds. 需要注意的是,如果设置了“startingdeadlineseconds”字段(而不是“nil”),则控制器将从“startingdeadlineseconds”的值到现在(而不是从上次计划的时间到现在)统计错过的作业数。例如,如果“startingdeadlineseconds”为“200”,则控制器将统计过去200秒内发生的未命中作业数。

A CronJob is counted as missed if it has failed to be created at its scheduled time. For example, If concurrencyPolicy is set to Forbid and a CronJob was attempted to be scheduled when there was a previous schedule still running, then it would count as missed. 如果未能在计划时间创建cronjob,则该cronjob将被计为未命中。例如,如果将“concurrency policy”设置为“forbid”,并且在前一个计划仍在运行时试图调度cronjob,则该cronjob将被计为missed。

For example, suppose a CronJob is set to schedule a new Job every one minute beginning at 08:30:00, and its startingDeadlineSeconds field is not set. If the CronJob controller happens to be down from 08:29:00 to 10:21:00, the job will not start as the number of missed jobs which missed their schedule is greater than 100. 例如,假设一个cronjob设置为从“08:30:00”开始每分钟调度一个新作业,而其“startingdeadlineseconds”字段未设置。如果cronjob控制器恰好从“08:29:00”降至“10:21:00”,则由于错过计划的错过作业数大于100,作业将不会启动。

To illustrate this concept further, suppose a CronJob is set to schedule a new Job every one minute beginning at 08:30:00, and its startingDeadlineSeconds is set to 200 seconds. If the CronJob controller happens to be down for the same period as the previous example (08:29:00 to 10:21:00,) the Job will still start at 10:22:00. This happens as the controller now checks how many missed schedules happened in the last 200 seconds (ie, 3 missed schedules), rather than from the last scheduled time until now. 为了进一步说明这个概念,假设一个cronjob被设置为从“08:30:00”开始每一分钟调度一个新作业,并且它的“startingdeadlineseconds”被设置为200秒。如果cronjob控制器恰巧在与前面的示例相同的时间段内关闭(08:29:00到`10:21:00',),则作业仍将在10:22:00开始。这是因为控制器现在检查在过去200秒内发生了多少个错过的计划(即,3个错过的计划),而不是从上一个计划时间到现在。

The CronJob is only responsible for creating Jobs that match its schedule, and the Job in turn is responsible for the management of the Pods it represents. cronjob只负责创建与其计划相匹配的作业,而作业则负责管理它所代表的pod。

Feedback

Was this page helpful?

k8s
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!