白皮书下载
Detailed explanation of timing expression Cron
The cron expression of timing setting is a string separated by 5 or 6 spaces and divided into 6 or 7 fields. Each field represents a meaning. Cron has the following two syntax formats: second minutes hours dayofmonth month DayOfWeek year or second minutes hours dayofmonth month DayOfWeek.
The characters that can appear in each field are as follows:
•Seconds:Four characters ", - * /" can appear, and the valid range is an integer from 0 to 59
•Minutes:Four characters ", - * /" can appear, and the valid range is an integer from 0 to 59
•Hours:Four characters ", - * /" can appear, and the valid range is an integer from 0 to 23
•DayofMonth:Eight characters of ", - * /? L W C" can appear, and the valid range is an integer from 0 to 31
•Month:Four characters of ", - * /" can appear, and the valid range is 1-12 integer or Jan Dec
•DayofWeek:Four characters ", - * /? L C #" can appear, and the valid range is an integer of 1-7 or sun-sat. (1 means Sunday, 2 means Monday, and so on)
•Year:Four characters of ", - * /" can appear, and the valid range is 1970-2099
Each field uses numbers, but the following special characters can also appear, which mean:
*: indicates any value matching the field, if used in the minutes field,,This means that an event is triggered every minute
?: can only be used in dayofmonth and DayOfWeek domains. It also matches any value of the field, but it doesn't. Because dayofmonth and DayOfWeek will affect each other. For example, if you want to trigger scheduling on the 20th of each month, no matter what day of the week the 20th is, you can only use the following expression: 13 13 15 20 *?, The last one can only use?, Instead of using, if usedIt means that it will trigger no matter what day of the week. In fact, it is not
-: indicates the range. For example, using 5-20 in the minutes field indicates that it is triggered every minute from 5 minutes to 20 minutes
/: indicates that the trigger starts at the start time and then is triggered every fixed time. For example, if 5 / 20 is used in the minutes field, it means that it is triggered every 5 minutes, while 25, 45, etc. are triggered respectively
,: indicates that enumeration values are listed. For example, using 5,20 in the minutes field means that it is triggered every minute at 5 and 20 minutes.
L: indicates that it can only appear in the DayOfWeek and dayofmonth domains. If 5L is used in the DayOfWeek domain, it means that it will be triggered on the last Thursday
W: indicates a valid working day (Monday to Friday). It can only appear in the dayofmonth field. The system will trigger an event on the latest valid working day from the specified date. For example, 5W is used in dayofmonth. If the 5th is Saturday, it will be triggered on the latest working day: Friday, i.e. the 4th. If the 5th is Sunday, it will be triggered on the 6th (Monday); If the 5th is one of Monday to Friday, it will be triggered on the 5th. On the other hand, w's recent search will not cross the month
LW: these two characters can be used together to represent the last working day of a month, that is, the last Friday.
#: used to determine the day of the week of each month. It can only appear in the dayofmonth field. For example, in 4#2, it means the second Wednesday of a month.
For example:
0 0 2 1 * ? * Indicates that the task is scheduled at 2 a.m. on the first day of each month;
0 15 10 ? * Mon-Fri means to perform the operation at 10:15 a.m. every day from Monday to Friday;
0 15 10 ? 6L 2002-2006 means that the operation is carried out at 10:15 a.m. on the last Friday of each month in 2002-2006;
A cron expression has at least 6 (and possibly 7) space separated time elements. In order: second (0 ~ 59) minute (0 ~ 59) hour (0 ~ 23) day (month) (0 ~ 31, but you need to consider the number of days in your month) month (0 ~ 11) day (week) (1 ~ 7 1 = sun or sun, Mon, Tue, wed, thu, Fri, SAT) year (1970-2099)
Each element can be a value (such as 6), a continuous interval (9-12), an interval (8-18 / 4) (/ means every 4 hours), a list (1,3,5), and wildcards. Because "date in month" and "date in week" are mutually exclusive, you must set one of them?
0 0 10,14,16 * * ? Every day at 10 a.m., 2 p.m. and 4 p.m
0 0/30 9-17 * * ? Every half an hour during nine to five working hours
0 0 12 ? * Wed means 12 noon every Wednesday
"0 0 12 * *?" is triggered at 12 noon every day
"0 15 10? * *" is triggered at 10:15 a.m. every day
"0 15 10 * *?" is triggered at 10:15 a.m. every day
"0 * *? *" is triggered at 10:15 a.m. every day
"0 15 10 * *? 2005" triggered at 10:15 am every day in 2005
"0 * 14 * *?" is triggered every 1 minute between 2:00 p.m. and 2:59 p.m. every day
"0 0 / 5 14 * *?" is triggered every 5 minutes between 2:00 p.m. and 2:55 p.m. every day
"0 0 / 5 14,18 * *?" is triggered every 5 minutes between 2 p.m. and 2:55 p.m. and between 6 p.m. and 6:55 p.m
"0 0-5 14 * *?" is triggered every 1 minute between 2 p.m. and 2:05 p.m. every day
"0 10,44 14? 3 wed" is triggered at 2:10 PM and 2:44 pm on Wednesday in March every year
"0 15 10? * Mon-Fri" is triggered at 10:15 am from Monday to Friday
"0 15 10 15 *?" triggered at 10:15 a.m. on the 15th of each month
"0 15 10 L *?" triggered at 10:15 a.m. on the last day of each month
"0 15 10? * 6L" is triggered at 10:15 a.m. on the last Friday of each month
"0 15 10? * 6L 2002-2005" triggered at 10:15 a.m. on the last Friday of each month from 2002 to 2005
"0 15 10? * 6#3" is triggered at 10:15 am on the third Friday of each month
Some subexpressions can contain ranges or lists
For example, the subexpression (day (week)) can be & ldquo; MON-FRI”,& ldquo; MON,WED,FRI”,& ldquo; MON-WED,SAT”
“*& rdquo; Character:Represents all possible values, therefore, & ldquo;” The meaning of each month is expressed in the sub expression (month), & ldquo;” Each day of the week is represented in the subexpression (day (week))
“/& rdquo; Character:Used to specify the increment of a numeric value, for example, & ldquo; in the subexpression (minutes); 0/15” Represents & ldquo; in the subexpression (minute) every 15 minutes from the 0 minute; 3/20” It means every 20 minutes from the 3rd minute (it has the same meaning as & ldquo; 3, 23, 43 & rdquo;)
“?& rdquo; Character:It is only used for day (month) and day (week) subexpressions, indicating that no value is specified. After one of the two subexpressions is specified with a value, in order to avoid conflict, the value of the other subexpression needs to be set to & ldquo& rdquo;
“ L” Character:It is only used in the two subexpressions of day (month) and day (week). It is the word & ldquo; last” But its meaning in the two sub expressions is different. In the day (month) subexpression, & ldquo; L” Represents the last day of a month. In the day (week) self expression, & ldquo; L” It means the last day of a week, that is, sat
If in & ldquo; L” If there is specific content before, it has other meanings
For example: & ldquo; 6L” Indicates the penultimate day of the month, & ldquo; FRIL” Indicates the last Friday of the month. Note: when using & ldquo; L” Do not specify a list or range when parameters are, as this can cause problems
field Allowable value Allowed special characters
second 0-59 , - * /
branch 0-59 , - * /
hour 0-23 , - * /
date 1-31 , - * ? / L W C
month 1-12 or Jan-Dec, - */
week 1-7 or sun-sat, - */ L C #
Year (optional) left blank, 1970-2099, - */




