Skip to content

Commit 4e945be

Browse files
committed
[zh] Sync /controllers/cron-jobs.md
1 parent 441de34 commit 4e945be

File tree

1 file changed

+55
-50
lines changed
  • content/zh-cn/docs/concepts/workloads/controllers

1 file changed

+55
-50
lines changed

content/zh-cn/docs/concepts/workloads/controllers/cron-jobs.md

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A _CronJob_ creates {{< glossary_tooltip term_id="job" text="Jobs" >}} on a repe
2828
2929
CronJob is meant for performing regular scheduled actions such as backups, report generation,
3030
and so on. One CronJob object is like one line of a _crontab_ (cron table) file on a
31-
Unix system. It runs a job periodically on a given schedule, written in
31+
Unix system. It runs a Job periodically on a given schedule, written in
3232
[Cron](https://en.wikipedia.org/wiki/Cron) format.
3333
-->
3434
**CronJob** 创建基于时隔重复调度的 {{< glossary_tooltip term_id="job" text="Job" >}}。
@@ -90,7 +90,7 @@ takes you through this example in more detail).
9090
### Schedule syntax
9191
The `.spec.schedule` field is required. The value of that field follows the [Cron](https://en.wikipedia.org/wiki/Cron) syntax:
9292
-->
93-
## 编写 CronJob 声明信息 {#writing-a-cronjob-spec}
93+
## 编写 CronJob 声明信息 {#writing-a-cronjob-spec}
9494

9595
### Cron 时间表语法 {#cron-schedule-syntax}
9696

@@ -102,9 +102,9 @@ The `.spec.schedule` field is required. The value of that field follows the [Cro
102102
# │ ┌───────────── hour (0 - 23)
103103
# │ │ ┌───────────── day of the month (1 - 31)
104104
# │ │ │ ┌───────────── month (1 - 12)
105-
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
106-
# │ │ │ │ │ 7 is also Sunday on some systems)
105+
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
107106
# │ │ │ │ │ OR sun, mon, tue, wed, thu, fri, sat
107+
# │ │ │ │ │
108108
# │ │ │ │ │
109109
# * * * * *
110110
```
@@ -114,7 +114,7 @@ The `.spec.schedule` field is required. The value of that field follows the [Cro
114114
# │ ┌───────────── 小时 (0 - 23)
115115
# │ │ ┌───────────── 月的某天 (1 - 31)
116116
# │ │ │ ┌───────────── 月份 (1 - 12)
117-
# │ │ │ │ ┌───────────── 周的某天 (0 - 6)(周日到周一;在某些系统上,7 也是星期日
117+
# │ │ │ │ ┌───────────── 周的某天 (0 - 6)(周日到周六
118118
# │ │ │ │ │ 或者是 sun,mon,tue,web,thu,fri,sat
119119
# │ │ │ │ │
120120
# │ │ │ │ │
@@ -192,49 +192,49 @@ You can specify common metadata for the templated Jobs, such as
192192
{{< glossary_tooltip text="annotations" term_id="annotation" >}}.
193193
For information about writing a Job `.spec`, see [Writing a Job Spec](/docs/concepts/workloads/controllers/job/#writing-a-job-spec).
194194
-->
195-
### 任务模板 {#job-template}
195+
### 任务模板 {#job-template}
196196

197197
`.spec.jobTemplate`为 CronJob 创建的 Job 定义模板,它是必需的。它和
198198
[Job](/zh-cn/docs/concepts/workloads/controllers/job/) 的语法完全一样,
199199
只不过它是嵌套的,没有 `apiVersion``kind`
200200
你可以为模板化的 Job 指定通用的元数据,
201201
例如{{< glossary_tooltip text="标签" term_id="label" >}}或{{< glossary_tooltip text="注解" term_id="annotation" >}}。
202-
有关如何编写一个任务的 `.spec`
202+
有关如何编写一个 Job 的 `.spec`
203203
请参考[编写 Job 规约](/zh-cn/docs/concepts/workloads/controllers/job/#writing-a-job-spec)
204204

205205
<!--
206-
### Deadline for delayed job start {#starting-deadline}
206+
### Deadline for delayed Job start {#starting-deadline}
207207
208208
The `.spec.startingDeadlineSeconds` field is optional.
209209
This field defines a deadline (in whole seconds) for starting the Job, if that Job misses its scheduled time
210210
for any reason.
211211
212212
After missing the deadline, the CronJob skips that instance of the Job (future occurrences are still scheduled).
213-
For example, if you have a backup job that runs twice a day, you might allow it to start up to 8 hours late,
213+
For example, if you have a backup Job that runs twice a day, you might allow it to start up to 8 hours late,
214214
but no later, because a backup taken any later wouldn't be useful: you would instead prefer to wait for
215215
the next scheduled run.
216216
-->
217-
### 任务延迟开始的最后期限 {#starting-deadline}
217+
### Job 延迟开始的最后期限 {#starting-deadline}
218218

219219
`.spec.startingDeadlineSeconds` 字段是可选的。
220-
它表示任务如果由于某种原因错过了调度时间,开始该任务的截止时间的秒数
220+
它表示 Job 如果由于某种原因错过了调度时间,开始该 Job 的截止时间的秒数
221221

222-
过了截止时间,CronJob 就不会开始该任务的实例(未来的任务仍在调度之中)。
223-
例如,如果你有一个每天运行两次的备份任务,你可能会允许它最多延迟 8 小时开始,但不能更晚,
222+
过了截止时间,CronJob 就不会开始该 Job 的实例(未来的 Job 仍在调度之中)。
223+
例如,如果你有一个每天运行两次的备份 Job,你可能会允许它最多延迟 8 小时开始,但不能更晚,
224224
因为更晚进行的备份将变得没有意义:你宁愿等待下一次计划的运行。
225225

226226
<!--
227227
For Jobs that miss their configured deadline, Kubernetes treats them as failed Jobs.
228228
If you don't specify `startingDeadlineSeconds` for a CronJob, the Job occurrences have no deadline.
229229
230230
If the `.spec.startingDeadlineSeconds` field is set (not null), the CronJob
231-
controller measures the time between when a job is expected to be created and
231+
controller measures the time between when a Job is expected to be created and
232232
now. If the difference is higher than that limit, it will skip this execution.
233233
234-
For example, if it is set to `200`, it allows a job to be created for up to 200
234+
For example, if it is set to `200`, it allows a Job to be created for up to 200
235235
seconds after the actual schedule.
236236
-->
237-
对于错过已配置的最后期限的 Job,Kubernetes 将其视为失败的任务
237+
对于错过已配置的最后期限的 Job,Kubernetes 将其视为失败的 Job
238238
如果你没有为 CronJob 指定 `startingDeadlineSeconds`,那 Job 就没有最后期限。
239239

240240
如果 `.spec.startingDeadlineSeconds` 字段被设置(非空),
@@ -247,28 +247,33 @@ CronJob 控制器将会计算从预期创建 Job 到当前时间的时间差。
247247
### Concurrency policy
248248
249249
The `.spec.concurrencyPolicy` field is also optional.
250-
It specifies how to treat concurrent executions of a job that is created by this CronJob.
250+
It specifies how to treat concurrent executions of a Job that is created by this CronJob.
251251
The spec may specify only one of the following concurrency policies:
252-
253-
* `Allow` (default): The CronJob allows concurrently running jobs
254-
* `Forbid`: The CronJob does not allow concurrent runs; if it is time for a new job run and the
255-
previous job run hasn't finished yet, the CronJob skips the new job run
256-
* `Replace`: If it is time for a new job run and the previous job run hasn't finished yet, the
257-
CronJob replaces the currently running job run with a new job run
258-
259-
Note that concurrency policy only applies to the jobs created by the same cron job.
260-
If there are multiple CronJobs, their respective jobs are always allowed to run concurrently.
261252
-->
262-
### 并发性规则 {#concurrency-policy}
253+
### 并发性规则 {#concurrency-policy}
263254

264-
`.spec.concurrencyPolicy` 也是可选的。它声明了 CronJob 创建的任务执行时发生重叠如何处理
255+
`.spec.concurrencyPolicy` 字段也是可选的。它声明了 CronJob 创建的 Job 执行时发生重叠如何处理
265256
spec 仅能声明下列规则中的一种:
266257

267-
* `Allow`(默认):CronJob 允许并发任务执行。
268-
* `Forbid`: CronJob 不允许并发任务执行;如果新任务的执行时间到了而老任务没有执行完,CronJob 会忽略新任务的执行。
269-
* `Replace`:如果新任务的执行时间到了而老任务没有执行完,CronJob 会用新任务替换当前正在运行的任务。
258+
<!--
259+
* `Allow` (default): The CronJob allows concurrently running Jobs
260+
* `Forbid`: The CronJob does not allow concurrent runs; if it is time for a new Job run and the
261+
previous Job run hasn't finished yet, the CronJob skips the new Job run. Also note that when the
262+
previous Job run finishes, `.spec.startingDeadlineSeconds` is still taken into account and may
263+
result in a new Job run.
264+
* `Replace`: If it is time for a new Job run and the previous Job run hasn't finished yet, the
265+
CronJob replaces the currently running Job run with a new Job run
266+
-->
267+
* `Allow`(默认):CronJob 允许并发 Job 执行。
268+
* `Forbid`:CronJob 不允许并发执行;如果新 Job 的执行时间到了而老 Job 没有执行完,CronJob 会忽略新 Job 的执行。
269+
另请注意,当老 Job 执行完成时,仍然会考虑 `.spec.startingDeadlineSeconds`,可能会导致新的 Job 执行。
270+
* `Replace`:如果新 Job 的执行时间到了而老 Job 没有执行完,CronJob 会用新 Job 替换当前正在运行的 Job。
270271

271-
请注意,并发性规则仅适用于相同 CronJob 创建的任务。如果有多个 CronJob,它们相应的任务总是允许并发执行的。
272+
<!--
273+
Note that concurrency policy only applies to the Jobs created by the same CronJob.
274+
If there are multiple CronJobs, their respective Jobs are always allowed to run concurrently.
275+
-->
276+
请注意,并发性规则仅适用于相同 CronJob 创建的 Job。如果有多个 CronJob,它们相应的 Job 总是允许并发执行的。
272277

273278
<!--
274279
### Schedule suspension
@@ -278,7 +283,7 @@ to true. The field defaults to false.
278283
279284
This setting does _not_ affect Jobs that the CronJob has already started.
280285
-->
281-
### 调度挂起 {#schedule-suspension}
286+
### 调度挂起 {#schedule-suspension}
282287

283288
通过将可选的 `.spec.suspend` 字段设置为 `true`,可以挂起针对 CronJob 执行的任务。
284289

@@ -294,31 +299,31 @@ you unsuspend the CronJob.
294299

295300
{{< caution >}}
296301
<!--
297-
Executions that are suspended during their scheduled time count as missed jobs.
302+
Executions that are suspended during their scheduled time count as missed Jobs.
298303
When `.spec.suspend` changes from `true` to `false` on an existing CronJob without a
299-
[starting deadline](#starting-deadline), the missed jobs are scheduled immediately.
304+
[starting deadline](#starting-deadline), the missed Jobs are scheduled immediately.
300305
-->
301-
在调度时间内挂起的执行都会被统计为错过的任务。当现有的 CronJob 将 `.spec.suspend``true` 改为 `false` 时,
302-
且没有[开始的最后期限](#starting-deadline)错过的任务会被立即调度
306+
在调度时间内挂起的执行都会被统计为错过的 Job。当现有的 CronJob 将 `.spec.suspend``true` 改为 `false` 时,
307+
且没有[开始的最后期限](#starting-deadline)错过的 Job 会被立即调度
303308
{{< /caution >}}
304309

305310
<!--
306311
### Jobs history limits
307312
308313
The `.spec.successfulJobsHistoryLimit` and `.spec.failedJobsHistoryLimit` fields are optional.
309-
These fields specify how many completed and failed jobs should be kept.
314+
These fields specify how many completed and failed Jobs should be kept.
310315
By default, they are set to 3 and 1 respectively. Setting a limit to `0` corresponds to keeping
311-
none of the corresponding kind of jobs after they finish.
316+
none of the corresponding kind of Jobs after they finish.
312317
313-
For another way to clean up jobs automatically, see [Clean up finished jobs automatically](/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically).
318+
For another way to clean up Jobs automatically, see [Clean up finished Jobs automatically](/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically).
314319
-->
315-
### 任务历史限制 {#jobs-history-limits}
320+
### 任务历史限制 {#jobs-history-limits}
316321

317322
`.spec.successfulJobsHistoryLimit``.spec.failedJobsHistoryLimit` 字段是可选的。
318-
这两个字段指定应保留多少已完成和失败的任务
319-
默认设置分别为 3 和 1。将限制设置为 `0` 代表相应类型的任务完成后不会保留
323+
这两个字段指定应保留多少已完成和失败的 Job
324+
默认设置分别为 3 和 1。将限制设置为 `0` 代表相应类型的 Job 完成后不会保留
320325

321-
有关自动清理任务的其他方式
326+
有关自动清理 Job 的其他方式
322327
请参见[自动清理完成的 Job](/zh-cn/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)
323328

324329
<!--
@@ -416,11 +421,11 @@ CronJob 根据其计划编排,在每次该执行任务的时候大约会创建
416421

417422
<!--
418423
If `startingDeadlineSeconds` is set to a large value or left unset (the default)
419-
and if `concurrencyPolicy` is set to `Allow`, the jobs will always run
424+
and if `concurrencyPolicy` is set to `Allow`, the Jobs will always run
420425
at least once.
421426
-->
422427
如果 `startingDeadlineSeconds` 设置为很大的数值或未设置(默认),并且
423-
`concurrencyPolicy` 设置为 `Allow`则作业将始终至少运行一次
428+
`concurrencyPolicy` 设置为 `Allow`则 Job 将始终至少运行一次
424429

425430
{{< caution >}}
426431
<!--
@@ -431,18 +436,18 @@ If `startingDeadlineSeconds` is set to a value less than 10 seconds, the CronJob
431436
{{< /caution >}}
432437

433438
<!--
434-
For every CronJob, the CronJob {{< glossary_tooltip term_id="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.
439+
For every CronJob, the CronJob {{< glossary_tooltip term_id="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.
435440
-->
436441
对于每个 CronJob,CronJob {{< glossary_tooltip term_text="控制器" term_id="controller" >}}
437442
检查从上一次调度的时间点到现在所错过了调度次数。如果错过的调度次数超过 100 次,
438-
那么它就不会启动这个任务,并记录这个错误:
443+
那么它就不会启动这个 Job,并记录这个错误:
439444

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

444449
<!--
445-
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.
450+
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.
446451
-->
447452
需要注意的是,如果 `startingDeadlineSeconds` 字段非空,则控制器会统计从
448453
`startingDeadlineSeconds` 设置的值到现在而不是从上一个计划时间到现在错过了多少次 Job。
@@ -458,7 +463,7 @@ A CronJob is counted as missed if it has failed to be created at its scheduled t
458463
<!--
459464
For example, suppose a CronJob is set to schedule a new Job every one minute beginning at `08:30:00`, and its
460465
`startingDeadlineSeconds` field is not set. If the CronJob controller happens to
461-
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.
466+
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.
462467
-->
463468
例如,假设一个 CronJob 被设置为从 `08:30:00` 开始每隔一分钟创建一个新的 Job,
464469
并且它的 `startingDeadlineSeconds` 字段未被设置。如果 CronJob 控制器从

0 commit comments

Comments
 (0)