Using Cron Expressions
A cron expression is a time expression used to specify the execution time, frequency, and interval of a scheduled task. It consists of six fields: Seconds, Minutes, Hours, Day of month, Month, and Week.
Field Values
Field |
Allowed Value |
Allowed Special Character |
Remarks |
---|---|---|---|
Seconds |
0–59 |
None |
None |
Minutes |
0–59 |
* / |
The task execution interval is greater than 30 minutes. |
Hours |
0–23 |
- * / |
None |
Dy of month |
1~31 |
- * ? / L |
None |
Month |
1–12 |
JAN-DEC - * / |
None |
Day of week |
1–7 |
SUN-SAT - * ? / L |
The value 1 indicates Sunday, the value 2 indicates Monday, and so on. |
Meaning of Special Characters
Character |
Description |
Example Value |
---|---|---|
* |
It can match any value of a field. |
If the Minutes field is set to *, an event is triggered every minute. |
? |
It can match any value of a field. However, it can be used only in the Day of month and Day of week fields because the two fields affect each other. |
To trigger scheduling on the 20th day of each month, regardless of the day of week, use the following format: 13 13 15 20 *? Because the 20th day is specified in the Day of month field, the last character of the Day of week field can only be a question mark (?) instead of an asterisk (*). If the last character is *, it indicates that the event is triggered on any day of a week, which is exclusive with the 20th day of the date field. In this case, the expression is incorrect. |
- |
A range |
For the Hours field, the value ranges from 8 to 10, indicating that the event is triggered every hour from 8:00 to 10:00. |
/ |
An event is triggered from the specified time and at a fixed interval. |
In the Hours field, */3 is equivalent to "every three hours." That is, an event is triggered at the following time points in a day: 0, 3, 6, 9, 12, 15, 18, and 21. |
L |
Indicates the end, which can appear only in the Day of month and Day of week fields. |
If 5L is used as the value of the Day of week field, the event is triggered on the last Thursday. |
Example Value
0 15 10 ? * *: indicates that a task is executed at 10:15 a.m. every day.
0 0 10,14,16 * * ?: indicates that a task is executed at 10:00 a.m., 14:00 p.m., and 16:00 p.m. every day.
0 40 9-17 * * ?: indicates that a task is executed at the 40th minute of each hour from 09:00 to 17:00 each day.
0 0/30 10-16 ? * 2: indicates that a task is executed every 30 minutes from 10:00 a.m. to 16:00 p.m. every Monday.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.