How to set a timed trigger rule?
Timed trigger rules support inputting Crontab expressions.
Caution: As Kubernetes uses UTC (Coordinated Universal Time), when setting the timed trigger rule for a scheduled task, if you need to set it to local time (such as Beijing time), you need to first convert the local time (GMT+8) to UTC time, and then convert the UTC time to a Crontab expression.
Conversion to UTC time
Time conversion rules: Local time - Time difference = UTC
Take BST to UTC time as an example:
Beijing is located in GMT+8, and the time difference between Beijing time and UTC time is 8 hours. The time conversion rule is:
Beijing time - 8 = UTC
Example 1: Convert Beijing time 9:42 to UTC time: 42 09 - 00 08 = 42 01, which means the UTC time is 1:42 AM.
Example 2: Convert Beijing time 4:32 AM to UTC time: 32 04 - 00 08 = -68 03. If it is a negative number, it means the previous day, and another conversion is needed: -68 03 + 00 24 = 32 20, which means the UTC time is 8:32 PM the previous day.
Write Crontab expressions
Basic Formats: minute hour day month week
Value range
| Minute | Hour | Day | Month | Week |
|---|---|---|---|---|
| [0-59] | [0-23] | [1-31] | [1-12] or [JAN-DEC] | [1-7] or [SUN-SAT] |
The following special characters are allowed in the minute, hour, day, month, and weekday fields:
,: Value list separator, used to specify multiple values. For example:1,2,5,7,8,9.-: Range of values specified by the user. For example:2-4, which means 2, 3, 4.*: Represents the entire time period. For example, when used in theminutefield, it means every minute./: Used to specify the increment of values. For example:n/mmeans starting from n, increment by m.
Common Examples
-
30 18 25 12 *means the task will be triggered at18:30:00on December 25th. -
30 18 25 * 6means the task will be triggered at18:30:00on the 25th of every month and every Saturday. -
30 18 * * 6means the task will be triggered at18:30:00every Saturday. -
* 18 * * *means the task will be triggered every minute (including18:00:00) starting from the nearest18:00:00. -
0 18 1,10,22 * *means the task will be triggered at18:00:00on the 1st, 10th, and 22nd of every month. -
0,30 18-23 * * *means the task will be triggered at00and30minutes past every hour between18:00and23:00every day. -
* */1 * * *means the task will be triggered every minute. -
* 2-7/1 * * *means the task will be triggered every minute between2:00and7:00every day. -
Inputting
0 11 4 * mon-wedmeans triggering the task at11:00 on the 4th day of every month and every Monday to Wednesday.