How Can I Configure the Time for Triggering a Scheduled Task of FDI?
Seconds Minutes Hours Day (day in each month) Month Week
Table 1 describes the meanings of each field in the QuartZ Cron expression.
Name |
Mandatory |
Optional Values |
Optional Special Characters |
---|---|---|---|
Seconds |
Yes |
0-59 |
, - * / |
Minutes |
Yes |
0-59 |
, - * / |
Hours |
Yes |
0-23 |
, - * / |
Day (day in each month) |
Yes |
1-31. Note that there are no 30 and 31 in February, and there is no 31 in April, June, September, and November. |
, - * ? / L W C |
Month |
Yes |
1-12 or a character string |
, - * / |
Week |
Yes |
1-7 or a character string |
, - * ? / L C # |
The month in a cron expression can be a number or character string. If you want to set the month to January, either 1 or JAN complies with the QuartZ Cron expression. For details about the mapping between numbers and character strings, see Table 2.
Numeral |
String |
---|---|
1 |
JAN |
2 |
FEB |
3 |
MAR |
4 |
APR |
5 |
MAY |
6 |
JUN |
7 |
JUL |
8 |
AUG |
9 |
SEP |
10 |
OCT |
11 |
NOV |
12 |
DEC |
The week in a QuartZ Cron expression can be a number or character string. If you want to set the day to Monday, either 2 or MON complies with the QuartZ Cron expression. For details about the mapping between numbers and character strings, see Table 3. The QuartZ Cron expression defines Saturday as the last day of each week.
Numeral |
String |
Description |
---|---|---|
1 |
SUN |
Sunday |
2 |
MON |
Monday |
3 |
TUE |
Tuesday |
4 |
WED |
Wednesday |
5 |
THU |
Thursday |
6 |
FRI |
Friday |
7 |
SAT |
Saturday |
Precautions
Besides numbers in each part, the following special characters can also be displayed:
- *: It can match any value of a field. If * is used in the minutes field, an event is triggered every minute.
- ?: It can only be used in two fields: day (day in each month) and week. It can also match any value of the field, but actually it does not. This is because day (day in each month) and week are mutually affected. For example, if you want to trigger scheduling on the 20th day of each month, you can use the following expression: 13 13 15 20 * ?, where the last digit can only be ?, but not *. If you use *, an event will be triggered regardless of the day of week.
- -: It specifies a range. For example, 5-20 in the minutes field means that an event is triggered every minute from minutes 5-20.
- /: An event is triggered from the specified time and at a fixed interval. For example, if you set the minutes field to 5/20, it means that the scheduled task will be triggered at the 5th, 25th, and 45th minutes of each hour.
- ,: It specifies a list value. For example, if you set the minutes field to 5,20, it means that the scheduled task will be triggered every minute between minutes 5 and 20 of each hour.
- L: It indicates the last. It can appear only in the day (day in each month) and week fields. For example, 5L in the day (day in each month) field means that the event is triggered on the last Thursday.
- W: It indicates a weekday (Monday to Friday) nearest the given day. It can appear only in the day (day of month) field. An event will be triggered on the valid weekday closest to the specified date. For example, 5W in the day (day of month) field means that an event will be triggered on the nearest weekday to the 5th day of the month. If the 5th day is Saturday, an event will be triggered on the 4th day (Friday). If the 5th day is Sunday, an event is triggered on the 6th day (Monday). If the 5th day is one day from Monday to Friday, an event is triggered on the 5th day. The trigger will not jump over the boundary of a month's days.
- LW: The two characters indicate the last weekday of a month, that is, the last Friday.
- #: It indicates the nth day of a week in each month. It can appear only in the day (day of week) field. For example, 4#2 indicates the second Wednesday of a month.
Examples
The following examples help you better understand the meanings of the QuartZ Cron expression. The simple examples show the primary use of QuartZ Cron expressions. The common examples show how to use QuartZ Cron expressions in actual scenarios. You only need to simply modify common examples based on site requirements.
0/5 * * * * ? //Executed every five seconds 0 0/1 * * * ? //Executed every one minute 0 0 23 * * ? //Executed at 23:00 every day 0 0 1 1 * ? //Executed at 01:00 on the first day of each month 0 0 23 L * ? //Executed at 23:00 on the last day of each month 0 33,55 * * * ? //Executed at the 33th and 55th minute 0 0 18 * * LW //Executed at 06:00 on the last weekday of each month
0 0 12 * * ? //Executed at 12:00 every day 0 * 14 * * ? //Executed every minute from 02:00 to 02:59 every day 0 0/30 9-17 * * ? //Executed every half an hour within working hours from 09:00 to 17:00 0 0 12 ? * WED //Executed at 12:00 every Wednesday 0 0/30 9-17 * * MON-FRI //Executed every half an hour from 09:00 to 17:00 every day from Monday to Friday 0 15 10 ? * MON-FRI //Executed at 10:15 every day from Monday to Friday 0 0 2 1 * ? //Executed at 02:00 on the first day of each month 0 15 10 ? * 6#3 //Executed at 10:15 on the third Friday of each month 0 15 10 ? * 6L //Executed at 10:15 on the last Friday of each month
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot