Skip to content

Commit 93e45c0

Browse files
authored
Merge pull request #40656 from windsonsea/topspr
[zh] sync /controllers/cron-jobs.md
2 parents 57a58a3 + e0b8ec7 commit 93e45c0

File tree

1 file changed

+56
-54
lines changed
  • content/zh-cn/docs/concepts/workloads/controllers

1 file changed

+56
-54
lines changed

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

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: CronJob
33
content_type: concept
44
weight: 80
55
---
6-
76
<!--
87
reviewers:
98
- erictune
@@ -21,9 +20,9 @@ weight: 80
2120
<!--
2221
A _CronJob_ creates {{< glossary_tooltip term_id="job" text="Jobs" >}} on a repeating schedule.
2322
24-
CronJob is meant for performing regular scheduled actions such as backups, report generation,
25-
and so on. One CronJob object is like one line of a _crontab_ (cron table) file on a
26-
Unix system. It runs a job periodically on a given schedule, written in
23+
CronJob is meant for performing regular scheduled actions such as backups, report generation,
24+
and so on. One CronJob object is like one line of a _crontab_ (cron table) file on a
25+
Unix system. It runs a job periodically on a given schedule, written in
2726
[Cron](https://en.wikipedia.org/wiki/Cron) format.
2827
-->
2928
**CronJob** 创建基于时隔重复调度的 {{< glossary_tooltip term_id="job" text="Job" >}}。
@@ -155,21 +154,21 @@ Other than the standard syntax, some macros like `@monthly` can also be used:
155154
除了标准语法,还可以使用一些类似 `@monthly` 的宏:
156155

157156
<!--
158-
| Entry | Description | Equivalent to |
159-
| ------------- | ------------- |------------- |
160-
| @yearly (or @annually) | Run once a year at midnight of 1 January | 0 0 1 1 * |
161-
| @monthly | Run once a month at midnight of the first day of the month | 0 0 1 * * |
162-
| @weekly | Run once a week at midnight on Sunday morning | 0 0 * * 0 |
163-
| @daily (or @midnight) | Run once a day at midnight | 0 0 * * * |
164-
| @hourly | Run once an hour at the beginning of the hour | 0 * * * * |
165-
-->
166-
| 输入 | 描述 | 相当于 |
167-
| ------------- | ------------- |------------- |
168-
| @yearly (或 @annually) | 每年 1 月 1 日的午夜运行一次 | 0 0 1 1 * |
169-
| @monthly | 每月第一天的午夜运行一次 | 0 0 1 * * |
170-
| @weekly | 每周的周日午夜运行一次 | 0 0 * * 0 |
171-
| @daily (或 @midnight) | 每天午夜运行一次 | 0 0 * * * |
172-
| @hourly | 每小时的开始一次 | 0 * * * * |
157+
| Entry | Description | Equivalent to |
158+
| ------------- | ------------- |------------- |
159+
| @yearly (or @annually) | Run once a year at midnight of 1 January | 0 0 1 1 * |
160+
| @monthly | Run once a month at midnight of the first day of the month | 0 0 1 * * |
161+
| @weekly | Run once a week at midnight on Sunday morning | 0 0 * * 0 |
162+
| @daily (or @midnight) | Run once a day at midnight | 0 0 * * * |
163+
| @hourly | Run once an hour at the beginning of the hour | 0 * * * * |
164+
-->
165+
| 输入 | 描述 | 相当于 |
166+
| ---------------------- | ------------------------ | ------------ |
167+
| @yearly (或 @annually) | 每年 1 月 1 日的午夜运行一次 | 0 0 1 1 * |
168+
| @monthly | 每月第一天的午夜运行一次 | 0 0 1 * * |
169+
| @weekly | 每周的周日午夜运行一次 | 0 0 * * 0 |
170+
| @daily (或 @midnight) | 每天午夜运行一次 | 0 0 * * * |
171+
| @hourly | 每小时的开始一次 | 0 * * * * |
173172

174173
<!--
175174
To generate CronJob schedule expressions, you can also use web tools like [crontab.guru](https://crontab.guru/).
@@ -318,74 +317,76 @@ For another way to clean up jobs automatically, see [Clean up finished jobs auto
318317

319318
<!--
320319
### Time zones
321-
322-
For CronJobs with no time zone specified, the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}} interprets schedules relative to its local time zone.
323320
-->
324321
## 时区 {#time-zones}
325322

323+
{{< feature-state for_k8s_version="v1.27" state="stable" >}}
324+
325+
<!--
326+
For CronJobs with no time zone specified, the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
327+
interprets schedules relative to its local time zone.
328+
-->
326329
对于没有指定时区的 CronJob,
327330
{{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
328331
基于本地时区解释排期表(Schedule)。
329332

330-
{{< feature-state for_k8s_version="v1.25" state="beta" >}}
333+
<!--
334+
You can specify a time zone for a CronJob by setting `.spec.timeZone` to the name
335+
of a valid [time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
336+
For example, setting `.spec.timeZone: "Etc/UTC"` instructs Kubernetes to interpret
337+
the schedule relative to Coordinated Universal Time.
338+
-->
339+
你可以通过将 `.spec.timeZone`
340+
设置为一个有效[时区](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)的名称,
341+
为 CronJob 指定一个时区。例如设置 `.spec.timeZone: "Etc/UTC"` 将告诉
342+
Kubernetes 基于世界标准时间解读排期表。
343+
344+
<!--
345+
A time zone database from the Go standard library is included in the binaries and used as a fallback in case an external database is not available on the system.
346+
-->
347+
Go 标准库中的时区数据库包含在二进制文件中,并用作备用数据库,以防系统上没有可用的外部数据库。
331348

332349
<!--
333-
If you enable the `CronJobTimeZone` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/),
334-
you can specify a time zone for a CronJob (if you don't enable that feature gate, or if you are using a version of
335-
Kubernetes that does not have experimental time zone support, all CronJobs in your cluster have an unspecified
336-
timezone).
350+
## CronJob limitations {#cron-job-limitations}
337351
338-
When you have the feature enabled, you can set `.spec.timeZone` to the name of a valid [time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). For example, setting
339-
`.spec.timeZone: "Etc/UTC"` instructs Kubernetes to interpret the schedule relative to Coordinated Universal Time.
352+
### Unsupported TimeZone specification
340353
-->
341-
如果启用了 `CronJobTimeZone` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
342-
你可以为 CronJob 指定一个时区(如果你没有启用该特性门控,或者你使用的是不支持试验性时区功能的
343-
Kubernetes 版本,集群中所有 CronJob 的时区都是未指定的)。
354+
## CronJob 的限制 {#cronjob-limitations}
344355

345-
启用该特性后,你可以将 `spec.timeZone`
346-
设置为有效[时区](https://zh.wikipedia.org/wiki/%E6%97%B6%E5%8C%BA%E4%BF%A1%E6%81%AF%E6%95%B0%E6%8D%AE%E5%BA%93)名称。
347-
例如,设置 `spec.timeZone: "Etc/UTC"` 指示 Kubernetes 采用 UTC 来解释排期表。
356+
### 不支持的时区规范 {#unsupported-timezone-spec}
348357

349-
{{< caution >}}
350358
<!--
351359
The implementation of the CronJob API in Kubernetes {{< skew currentVersion >}} lets you set
352360
the `.spec.schedule` field to include a timezone; for example: `CRON_TZ=UTC * * * * *`
353361
or `TZ=UTC * * * * *`.
362+
-->
363+
Kubernetes {{< skew currentVersion >}} 中的 CronJob API 实现允许你设置
364+
`.spec.schedule` 字段,在其中包括时区信息;
365+
例如 `CRON_TZ=UTC * * * * *``TZ=UTC * * * * *`
354366

367+
<!--
355368
Specifying a timezone that way is **not officially supported** (and never has been).
356369
357370
If you try to set a schedule that includes `TZ` or `CRON_TZ` timezone specification,
358371
Kubernetes reports a [warning](/blog/2020/09/03/warnings/) to the client.
359-
Future versions of Kubernetes might not implement that unofficial timezone mechanism at all.
372+
Future versions of Kubernetes will prevent setting the unofficial timezone mechanism entirely.
360373
-->
361-
Kubernetes {{< skew currentVersion >}} 中 CronJob API 的实现允许你设置
362-
`.spec.schedule` 字段以包含时区;例如:`CRON_TZ=UTC * * * * *``TZ=UTC * * * * *`
363-
364-
以这种方式指定时区是**未正式支持**(而且从来没有)。
374+
以这种方式指定时区是 **未正式支持的**(而且也从未正式支持过)。
365375

366376
如果你尝试设置包含 `TZ``CRON_TZ` 时区规范的排期表,
367-
Kubernetes 会向客户端报告[警告](/zh-cn/blog/2020/09/03/warnings/)
368-
Kubernetes 的未来版本可能根本不会实现这种非正式的时区机制。
369-
{{< /caution >}}
377+
Kubernetes 会向客户端报告一条[警告](/blog/2020/09/03/warnings/)
378+
后续的 Kubernetes 版本将完全阻止设置非正式的时区机制。
370379

371380
<!--
372-
A time zone database from the Go standard library is included in the binaries and used as a fallback in case an external database is not available on the system.
373-
-->
374-
Go 标准库中的时区数据库包含在二进制文件中,并用作备用数据库,以防系统上没有可用的外部数据库。
375-
376-
<!--
377-
## CronJob limitations {#cron-job-limitations}
378-
379381
### Modifying a CronJob
382+
380383
By design, a CronJob contains a template for _new_ Jobs.
381384
If you modify an existing CronJob, the changes you make will apply to new Jobs that
382385
start to run after your modification is complete. Jobs (and their Pods) that have already
383386
started continue to run without changes.
384387
That is, the CronJob does _not_ update existing Jobs, even if those remain running.
385388
-->
386-
## CronJob 限制 {#cronjob-limitations}
387-
388-
### 修改 CronJob {#modifying-a-cronjob}
389+
### 修改 CronJob {#modifying-a-cronjob}
389390

390391
按照设计,CronJob 包含一个用于**** Job 的模板。
391392
如果你修改现有的 CronJob,你所做的更改将应用于修改完成后开始运行的新任务。
@@ -491,7 +492,8 @@ CronJob 仅负责创建与其调度时间相匹配的 Job,而 Job 又负责管
491492
Read the {{< api-reference page="workload-resources/cron-job-v1" >}}
492493
API reference for more details.
493494
-->
494-
* 了解 CronJob 所依赖的 [Pod](/zh-cn/docs/concepts/workloads/pods/)[Job](/zh-cn/docs/concepts/workloads/controllers/job/) 的概念。
495+
* 了解 CronJob 所依赖的 [Pod](/zh-cn/docs/concepts/workloads/pods/)
496+
[Job](/zh-cn/docs/concepts/workloads/controllers/job/) 的概念。
495497
* 阅读 CronJob `.spec.schedule` 字段的详细[格式](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format)
496498
* 有关创建和使用 CronJob 的说明及 CronJob 清单的示例,
497499
请参见[使用 CronJob 运行自动化任务](/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/)

0 commit comments

Comments
 (0)