Skip to content

Commit b96fc31

Browse files
authored
Merge pull request #30542 from cndoit18/unsupported-cron-tz
[zh]: Add warning about using unsupported CRON_TZ
2 parents 0aa00b6 + 65b7de8 commit b96fc31

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

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

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ A _CronJob_ creates {{< glossary_tooltip term_id="job" text="Jobs" >}} on a repe
1919
2020
One CronJob object is like one line of a _crontab_ (cron table) file. It runs a job periodically
2121
on a given schedule, written in [Cron](https://en.wikipedia.org/wiki/Cron) format.
22-
23-
In addition, the CronJob schedule supports timezone handling, you can specify the timezone by adding "CRON_TZ=<time zone>" at the beginning of the CronJob schedule, and it is recommended to always set `CRON_TZ`.
2422
-->
2523
_CronJob_ 创建基于时隔重复调度的 {{< glossary_tooltip term_id="job" text="Jobs" >}}。
2624

2725
一个 CronJob 对象就像 _crontab_ (cron table) 文件中的一行。
2826
它用 [Cron](https://en.wikipedia.org/wiki/Cron) 格式进行编写,
2927
并周期性地在给定的调度时间执行 Job。
3028

31-
另外,CronJob 调度支持时区处理,你可以通过在 CronJob schedule 字段的开头添加 "CRON_TZ=<time zone>" 指定时区,且建议始终设置 `CRON_TZ`
32-
3329
<!--
3430
All **CronJob** `schedule:` times are based on the timezone of the
3531
@@ -47,6 +43,24 @@ that the cron job controller uses.
4743
那么为该容器所设置的时区将会决定 Cron Job 的控制器所使用的时区。
4844
{{< /caution >}}
4945

46+
<!--
47+
The [v1 CronJob API](/docs/reference/kubernetes-api/workload-resources/cron-job-v1/)
48+
does not officially support setting timezone as explained above.
49+
50+
Setting variables such as `CRON_TZ` or `TZ` is not officially supported by the Kubernetes project.
51+
`CRON_TZ` or `TZ` is an implementation detail of the internal library being used
52+
for parsing and calculating the next Job creation time. Any usage of it is not
53+
recommended in a production cluster.
54+
-->
55+
56+
{{< caution >}}
57+
[v1 CronJob API](/zh/docs/reference/kubernetes-api/workload-resources/cron-job-v1/) 所述,官方并不支持设置时区。
58+
59+
Kubernetes 项目官方并不支持设置如 `CRON_TZ` 或者 `TZ` 等变量。
60+
`CRON_TZ` 或者 `TZ` 是用于解析和计算下一个 Job 创建时间所使用的内部库中一个实现细节。
61+
不建议在生产集群中使用它。
62+
{{< /caution>}}
63+
5064
<!--
5165
When creating the manifest for a CronJob resource, make sure the name you provide
5266
is a valid [DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
@@ -96,16 +110,15 @@ This example CronJob manifest prints the current time and a hello message every
96110
### Cron 时间表语法
97111

98112
```
99-
# ┌────────────────── 时区 (可选)
100-
# | ┌───────────── 分钟 (0 - 59)
101-
# | │ ┌───────────── 小时 (0 - 23)
102-
# | │ │ ┌───────────── 月的某天 (1 - 31)
103-
# | │ │ │ ┌───────────── month (1 - 12)
104-
# | │ │ │ │ ┌───────────── 周的某天 (0 - 6)(周日到周一;在某些系统上,7 也是星期日)
105-
# | │ │ │ │ │
106-
# | │ │ │ │ │
107-
# | │ │ │ │ │
108-
# CRON_TZ=UTC * * * * *
113+
# ┌───────────── 分钟 (0 - 59)
114+
# │ ┌───────────── 小时 (0 - 23)
115+
# │ │ ┌───────────── 月的某天 (1 - 31)
116+
# │ │ │ ┌───────────── 月份 (1 - 12)
117+
# │ │ │ │ ┌───────────── 周的某天 (0 - 6)(周日到周一;在某些系统上,7 也是星期日)
118+
# │ │ │ │ │
119+
# │ │ │ │ │
120+
# │ │ │ │ │
121+
# * * * * *
109122
```
110123

111124
```
@@ -114,7 +127,7 @@ This example CronJob manifest prints the current time and a hello message every
114127
# │ │ ┌───────────── 月的某天 (1 - 31)
115128
# │ │ │ ┌───────────── 月份 (1 - 12)
116129
# │ │ │ │ ┌───────────── 周的某天 (0 - 6) (周日到周一;在某些系统上,7 也是星期日)
117-
# │ │ │ │ │
130+
# │ │ │ │ │
118131
# │ │ │ │ │
119132
# │ │ │ │ │
120133
# * * * * *
@@ -138,11 +151,11 @@ This example CronJob manifest prints the current time and a hello message every
138151
| @hourly | 每小时的开始一次 | 0 * * * * |
139152

140153
<!--
141-
For example, the line below states that the task must be started every Friday at midnight, as well as on the 13th of each month at midnight(in UTC):
154+
For example, the line below states that the task must be started every Friday at midnight, as well as on the 13th of each month at midnight:
142155
-->
143-
例如,下面这行指出必须在每个星期五的午夜以及每个月 13 号的午夜开始任务(UTC 时间)
156+
例如,下面这行指出必须在每个星期五的午夜以及每个月 13 号的午夜开始任务:
144157

145-
`CRON_TZ=UTC 0 0 13 * 5`
158+
`0 0 13 * 5`
146159

147160
<!--
148161
To generate CronJob schedule expressions, you can also use web tools like [crontab.guru](https://crontab.guru/).

0 commit comments

Comments
 (0)