Appendix: Quartz Cron Expression Configuration
Parameter Description
Quartz cron expressions can be used to schedule data integration tasks.
A Quartz cron expression contains six fields separated by space, in the following format.
Second Minute Hour Day Month Week
Table 1 describes the parameters.
Name |
Mandatory |
Optional Value |
Optional Special Character |
---|---|---|---|
Second |
No To be supported |
Fixed at 0 |
- |
Minute |
Yes |
0–59 |
, - * / |
Hour |
Yes |
0–23 |
, - * / |
Day |
Yes |
Day of a month, ranging from 1 to 31. Note that there are no 30 and 31 in February, and there is no 31 in April, June, September, and November. |
, - * ? / L W |
Month |
Yes |
1–12 or a character string. For the mapping between numbers and character strings, see Table 2. Example: Enter 1 or JAN if you want to specify January. |
, - * / |
Week |
Yes |
1–7 or a character string. For details about the mapping between numbers and character strings, see Table 3. In Quartz cron expressions, Saturday is the last day of a week. Example: Enter 2 or MON if you want to specify Monday. |
, - * ? / L # |
Precautions
Each parameter value is a number, but the following special characters can also be used:
- *: 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 "last". It can appear only in the day (day in each month) and week fields. For example, 5L in the week field means that a task is triggered on the last Thursday of the month.
- W: It indicates the weekday (Monday to Friday) nearest the given day. It can appear only in the day (day of month) field. For example, 5W in the day (day of month) field means that a task is triggered on the nearest weekday to the 5th day of the month. If the 5th day is Saturday, the task is triggered on the 4th day (Friday). If the 5th day is Sunday, the task 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 every month. It can appear only in the day (day of month) field. For example, 4#2 indicates the second Wednesday of a month.
When configuring the Quartz Cron expression for a scheduled task, pay attention to the following::
Quartz Cron uses UTC+0. Convert local time to UTC+0. For example, China is UTC+8, so to run a daily task at 20:00 China time, subtract 8 hours. The Quartz Cron is 0 12 * * ?.
Configuration Example
The following examples show you how to use Quartz cron expressions.
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-19 * *? //Executed every half an hour from 9:00 a.m. to 19:59 p.m. 0 0 12 ? * WED //Executed at 12:00 every Wednesday 0 0/30 9-19 * * MON-FRI //Executed every half an hour from 09:00 to 19:59 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