Spring—Quartz timing scheduling CronTrigger time configuration format description and example

Go to http://blog.csdn.net/foamflower/article/details/4260645


1. CronTrigger time format configuration instructions

CronTrigger configuration format:
format: [seconds] [minutes] [hours] [days] [months] [weeks] [Year]

No. Description Required or not Allowed values ​​Allowed wildcards
1 second is 0-59 , - * /
2 minutes is 0-59 , - * /
3 hours is 0-23 , - * /
4 days is 1- 31 , -* ? / LW
May yes 1-12 or JAN-DEC , -* /|
6 weeks yes 1-7 or SUN-SAT , -* ? / L#
7 years no empty or 1970-2099 , -* /


Wildcard description:
* : Indicates all values. For example: setting "*" on the field of minutes means that it will be triggered every minute.
? : Indicates that no value is specified. The use case is that you don't need to care about the value of the current setting of this field. For example: to trigger an operation on the 10th of each month, but don't care about the day of the week, so the field that needs the week position is set to "?" Specifically set to 0 0 0 10 * ?
- : indicates the interval. For example, setting "10-12" on the hour means that it will be triggered at 10, 11, and 12 o'clock.
, : Indicates specifying multiple values, such as setting "MON,WED,FRI" on the week field to indicate Monday, Wednesday and Friday triggering
/ : for incremental triggering. If "5/15" is set on the second, it starts from 5 seconds and triggers every 15 seconds (5, 20, 35, 50). Set '1/3' on the month field to start on the 1st of each month and trigger every three days.
L : Indicates the last meaning. On the day field setting, it means the last day of the current month (according to the current month, if it is February, it will also depend on whether it is a leap year [leap]), and on the week field it means Saturday, which is equivalent to "7" or "SAT". If you add a number before "L", it means the last of the data.
For example, if you set the format of "6L" on the week field, it means "the last Friday of this month"
W : Indicates the nearest working day (Monday to Friday) from the specified date. For example, if you set "15W" on the day field, Indicates that it is triggered on the working day closest to the 15th of each month. If the 15th happens to be Saturday, it will trigger on the nearest Friday (14th), if the 15th is a weekday, it will trigger on the nearest next Monday (16th). If the 15th happens to be on a working day (Monday to Weekly) 5), it will be triggered on that day. If the specified format is "1W", it means that it will be triggered on the nearest working day after the 1st of each month. If the 1st falls on a Saturday, it will trigger on the following Monday, the 3rd. (Note, only specific numbers can be set before "W", and interval "-" is not allowed).
' L' and 'W' can be used in combination. If "LW" is set on the day field, it means to fire on the last working day of the month

# : Serial number (indicates the day of the week of the month), for example, setting "6#3" on the week field means Saturday in the third week of the month. Note that if "6#5" is specified, it is exactly the fifth week If there is no Saturday, the configuration will not be triggered (it is suitable for Mother's Day and Father's Day)
. The setting of the week field is case-insensitive if English letters are used. MON is the same as mon.

Common example:

format: [seconds] [minutes] [hours] [days] [months] [weeks] [years]
0 0 12 * * ? Every day at 12:00
0 15 10 ? * * Every day at 10:15
0 15 10 * * ? every day at 10:15 Minute trigger 
0 15 10 * * ? * Every day at 10:15 trigger 
0 15 10 * * ? 2005 In 2005 every day at 10:15 trigger
0 * 14 * * ? Every day from 2:00 to 2:59 in the afternoon trigger
0 0/5 14 * * ? Every day from 2:00 to 2:59 pm (start on the hour, trigger every 5 minutes) 
0 0/5 14,18 * * ? Every day from 18:00 to 18:59 pm (on the whole every 5 minutes)

0 0-5 14 * * ? Every day from 2:00 pm to 2:05 pm
0 10,44 14 ? 3 WED every Wednesday at 2:10 pm and Triggered at 2:44
0 15 10 ? *MON-FRI Triggered at 10:15 am every day from Monday to Friday
0 15 10 15 * ? Triggered at 10:15 am on the 15th of every month
0 15 10 L * ? Triggered at 10:15 am on the last day of
each month
0 15 10 ? * 6L 2002-2005 Triggered at 10:15 on Friday of the last week of every month from 2002 to 2005

0 15 10 ? * 6#3 Triggered on Friday of the third week of every month
0 0 12 1/ 5 * ? Trigger every 5 days from the first noon of every
month

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326267760&siteId=291194637