When the update frequency you want to set is complicated and can not be achieved by Execute Repeatedly or Set Detailed Frequency, we can use a Cron expression.
This document shows you how to set a Cron expression.
The Cron expression is described in the form of a string. The structure of the Cron expression typically consists of six or seven fields, with each field representing a time range and separated by five or six spaces. The Cron expression can be written as the following two syntax formats.
Seconds Minutes Hours DayofMonth Month DayofWeek Year
Seconds Minutes Hours DayofMonth Month DayofWeek
Each field can be described as the following characters.
Field
Allowed Value
Allowed Special Character
Seconds
0 to 59 (integers)
, - * and / (four characters)
Minutes
Hours
0 to 23 (integers)
DayofMonth
0 to 31 (integers, the number of which depends on the specific month)
, - * ? / L W and C (eight characters)
Month
1 to 12 (integers) or JAN to DEC (abbreviation of the month name)
DayofWeek
1 to 7 (integers) or SUN to SAT (1=SUN, 2=MON, ...)
, - * ? L C and # (eight characters)
Year
1970 to 2099
In addition to numbers, each field can be described as special characters, and the meanings of these special characters are as follows.
Character
Definition
*
Indicates any values that match the field. If Minutes is described as *, then the field means that the event will be
triggered per minute.
?
Only appears in DayofMonth and DayofWeek. This character also indicates any values that match the two fields, but
in fact it does not, because DayofMonth and DayofWeek will affect each other. For example, if you want to trigger
scheduling on the 20th of every month, no matter what day of the week the 20th is, you only can write the syntax
as: 13 13 15 20 * ?, and the last character can only be ?, rather than *. Because if you use * to describe
DayofWeek, the problem is that there is a contradiction between "the 20th of every month" and "any day of the
week".
-
Indicates the range. For example, If Minutes is described as 5 - 20, and then the field means the event will be triggered per minute from 5 to 20 minutes.
/
Indicates that the event will be triggered at the start time and then be triggered at each fixed interval. For example,
If Minutes is described as 5/20, then the field means that the event will start to be triggered at five minutes and
continued to be triggered every 20 minutes. (The event will be triggered at 25 minutes, 45 minutes and so on.)
,
Indicates to list enumeration values. For example, If Minutes is described as 5,20, then the field means that the event will be triggered at 5 and 20 minutes respectively.
L
Represents "Last" and only appears in DayofMonth and DayofWeek. However, this character has different meanings
in the two fields. L represents the last day of a month in DayofMonth, for example the 31st of January, or the 28th of February in non-leap year. If DayofWeek is described as L, then the field means Saturday, tantamount to 7. However, if there is a numerical value X before L, the character L takes on a different meaning. For example, 6L in
DayofMonth means the sixth-to-last day of the month, and FRIL in DayofWeek means the last Friday of the month.
W
Modifies the preceding date and only appears in DayofMonth. This character means the nearest weekday
(Monday to Friday) to that date. For example, 15W represents the nearest weekday (Monday to Friday) to the 15th
of the month. If the 15th of that month falls on a Saturday, then the character represents the 14th (Friday). If the 15th falls on a Sunday, then it represents the 16th (Monday). And if the 15th falls on a Tuesday, then it represents the 15th (Tuesday). However, the associated representing date cannot cross months. For example, if you specify 1W and the 1st falls on a Saturday, then the field will represent the 3rd (Monday) of the current month, not the last day of the
previous month. The W string can only specify a single date, not a date range.
LW
Can appear in DayofMonth in combination. This character means the last workday of the month (Monday to Friday).
C
Means "Calendar" and only appears in DayofMonth and DayofWeek. This character means to schedule the
associated date. If the date is not associated, then the character represents all dates in the calendar. For example,
5C in DayofMonth is equivalent to the first day after five days on the calendar. 1C in DayofWeek is equivalent to the
first day after Sunday.
#
Indicates a certain workday of the month (Monday to Friday) and only appears in DayofWeek. For example, 6#3
represents the third Friday of the month (6 represents Friday, #3 represents the third), while 4#5 represents the fifth Wednesday of the month. If there is no fifth Wednesday in the month, then the field is ignored and can not be
triggered.
For example, you want the folder of Department Data to be updated every Monday to Friday at 8:00.
1. Choose Public Data, select the folder of Department Data and select Folder Update, as shown in the following figure.
2. Click Schedule Setting.
3. Set Execution Frequency to Set Expression on the Scheduled Update setting page, and enter the corresponding Cron expression.
This Cron expression means that the update is executed every Monday to Friday at 8:00.
4. Click OK, and now the setting is successful.
The Cron expression can be further expanded here.
Expression
0 0 8 ? * 2-6
Means being executed every Monday to Friday at 8:00.
0 0/5 8-9 ? * 2-6
Means being executed every five minutes between 8:00 and 9:00, from Monday to Friday.
0 0 8,17 ? * 2-6
Means being executed at 8:00 and 17:00 from Monday to Friday.
Common Scenario
0 0 8,13 * * ?
Means being executed at 8:00 and 13:00 every day.
0 0 8-18 ? * MON-FRI
Means being executed at each hour from 8:00 to 18:00 (during regular working hours), from Monday to Friday.
0 0 12 ? * 2#1
Means being executed at 12:00 on the first Monday of every month.
0 * 14 * * ?
Means starting to be executed at 14:00 and continued to be executed per minute from 14:00 to 14:59 every day.
0 0/5 14 * * ?
Means starting to be executed at 14:00 and continued to be executed every five minutes from 14:00 to 14:55 every day.
0 55/10 14,18 * * ?
Means being executed at 14:55 and 18:55 every day.
0 10,44 14 ? 3 WED
Means being executed every Wednesday in March at 14:10 and 14:44.
0 15 10 ? * MON-FRI
Means being executed at 10:15 every Monday, Tuesday, Wednesday, Thursday, and Friday.
0 15 10 15 * ?
Means being executed at 10:15 on the 15th of every month.
0 15 10 L * ?
Means being executed at 10:15 on the last day of every month.
0 15 10 ? * 6L
Means being executed at 10:15 on the last Friday of every month.
0 15 10 ? * 6L 2002-2005
Means being executed at 10:15 on the last Friday of every month from 2002 to 2005.
0 15 10 ? * 6#3
Means being executed at 10:15 on the third Friday of every month.
0 0 0 L-2 * ? *
Means being executed on the second-to-last day of every month.
Simple Scenario
*/5 * * * * ?
Means being executed every five minutes.
0 */1 * * * ?
Means being executed every one minute.
0 0 */1 * * ?
Means being executed every one hour.
0 0 12 * * ?
Means being executed at 12:00 every day.
0 0 0,13,18,21 * * ?
Means being executed at 00:00, 13:00 and 21:00 every day.
0 0 0-8 * * ?
Means being executed at each hour from 00:00 to 8:00 every day.
0 15 10 ? * *
Means being executed at 10:15 every morning.
0 15 10 * * ?
0 15 10 * * ? *
0 15 10 * * ? 2024
Means being executed at 10:15 every morning in 2024.
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy