Skip to content

Commit 0aa00b6

Browse files
authored
Merge pull request #30509 from soltysh/cronjob_warning
Add warning about using unsupported CRON_TZ
2 parents d54f091 + b5e83e8 commit 0aa00b6

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ A _CronJob_ creates {{< glossary_tooltip term_id="job" text="Jobs" >}} on a repe
1717
One CronJob object is like one line of a _crontab_ (cron table) file. It runs a job periodically
1818
on a given schedule, written in [Cron](https://en.wikipedia.org/wiki/Cron) format.
1919

20-
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`.
21-
2220
{{< caution >}}
2321
All **CronJob** `schedule:` times are based on the timezone of the
2422
{{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}.
@@ -28,6 +26,16 @@ containers, the timezone set for the kube-controller-manager container determine
2826
that the cron job controller uses.
2927
{{< /caution >}}
3028

29+
{{< caution >}}
30+
The [v1 CronJob API](/docs/reference/kubernetes-api/workload-resources/cron-job-v1/)
31+
does not officially support setting timezone as explained above.
32+
33+
Setting variables such as `CRON_TZ` or `TZ` is not officially supported by the Kubernetes project.
34+
`CRON_TZ` or `TZ` is an implementation detail of the internal library being used
35+
for parsing and calculating the next Job creation time. Any usage of it is not
36+
recommended in a production cluster.
37+
{{< /caution >}}
38+
3139
When creating the manifest for a CronJob resource, make sure the name you provide
3240
is a valid [DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
3341
The name must be no longer than 52 characters. This is because the CronJob controller will automatically
@@ -55,16 +63,15 @@ takes you through this example in more detail).
5563
### Cron schedule syntax
5664

5765
```
58-
# ┌────────────────── timezone (optional)
59-
# | ┌───────────── minute (0 - 59)
60-
# | │ ┌───────────── hour (0 - 23)
61-
# | │ │ ┌───────────── day of the month (1 - 31)
62-
# | │ │ │ ┌───────────── month (1 - 12)
63-
# | │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
64-
# | │ │ │ │ │ 7 is also Sunday on some systems)
65-
# | │ │ │ │ │
66-
# | │ │ │ │ │
67-
# CRON_TZ=UTC * * * * *
66+
# ┌───────────── minute (0 - 59)
67+
# │ ┌───────────── hour (0 - 23)
68+
# │ │ ┌───────────── day of the month (1 - 31)
69+
# │ │ │ ┌───────────── month (1 - 12)
70+
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
71+
# │ │ │ │ │ 7 is also Sunday on some systems)
72+
# │ │ │ │ │
73+
# │ │ │ │ │
74+
# * * * * *
6875
```
6976

7077

@@ -78,9 +85,9 @@ takes you through this example in more detail).
7885

7986

8087

81-
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):
88+
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:
8289

83-
`CRON_TZ=UTC 0 0 13 * 5`
90+
`0 0 13 * 5`
8491

8592
To generate CronJob schedule expressions, you can also use web tools like [crontab.guru](https://crontab.guru/).
8693

0 commit comments

Comments
 (0)