A cron trigger is the time that a cron expression is used to configure a task.
Description of Cron expressions
A cron expression has a total of 7 values, one of which is optional, as follows (from official documents):
value |
must |
allowable range of values |
allowed characters |
seconds |
yes |
0-59 |
,-*/ |
minutes |
yes |
0-59 |
,-*/ |
hours |
yes |
0-23 |
,-*/ |
day of month |
yes |
1-31 |
,-*? /L W |
month |
yes |
1-12 or Jan-dec |
,-*/ |
day of week |
yes |
1-7 or Sun-sat |
,-*? /L # |
Year |
NO |
Empty, 1970-2099 |
, - * / |
Cr on-expression string description
The example string for a cron expression is "0 0 12?" * WED ", which means" 12:00 noon every Wednesday ". A single child expression can contain a range or a list. For example: The days of the week in the previous example this field (here is "WED") can be replaced with "Mon-fri", "MON, WED, FRI" or even "Mon-wed,sat". Wildcard <strong> (' * ') </strong> can be used to represent "each" possible value in the domain. Therefore, the * in the month field represents each month, while the * in the Day-of-week field represents "Every day of the week". All of the values in the domain have a specific legal scope, the legal range of these values is quite obvious, for example: the legal value of the second and the domain is 0 to 59, the legal range of the hour is 0 to 23,day-of-month is worth legal where the range is 0 to 31, but you need to be aware of the different days in different months. The legal value for the month is 0 to 11. or use the string Jan,feb MAR, APR, May, June, JUL,, SEP, OCT, NOV and Dec to indicate. Days-of-week can be represented by 1 to 7来 (1= Sunday) or by using the string sun, MON, TUE, WED, THU, FRI, and sat to denote .<strong> '/' </strong> characters used to represent the increment of the value, for example , if you put ' 0/15 ' in the minute field, it means "every 15 minutes, starting from 0", if you use ' 3/20 ' in the part of the domain, it means "every 20 minutes in the hour, starting from the 3rd minute" or the other same form is ' 3,23,43 '. <strong> '? ' The </strong> characters can be used in the Day-of-month and Day-of-week fields, which are used to indicate "no value specified". This is useful when you need to specify a value for one or two fields without having to set up other domains. <strong> ' L ' </strong> characters can be used in Day-of-month and Day-of-week, which is shorthand for "last", but has a different meaning in two domains. For example, the "L" in the Day-of-month field represents the last day of the month, that is, 31st of January, non-leap year February of 28th. If it is used in day-of-week, it means "7" or "SAT". However, if the character is followed by a different value in the Day-of-week field, the last week of the month is xxx. For example, "6L" or "Fril" represent the mostAfter a Friday. When using the ' L ' option, the most important thing is not to specify a list or range of values, which can cause confusion. The <strong> ' W ' </strong> character is used to specify the closest number of weeks (specified in the Day-of-week field) to the nearest day. For example: If you specify "15W" for the Day-of-month field, it means "the nearest week of the month 15th". <strong> ' # ' </strong> represents the week ordinal of the month. For example: "6#3" or "fri#3" in the Day-of-week field means "third Friday of the month".
Excerpt from blog http://www.cnblogs.com/shanyou/archive/2007/08/25/869073.html
A new character was added in version 2.3.1
" ," the comma represents an additional value, such as "Mon,wed,fri", which means three days
Cron expression Examples (excerpt from official documents)
An expression |
meaning |
0 0 12 * *? |
12am a Day |
0 15 10? * * |
Daily 10:15am |
0 15 10 * *? |
Daily 10:15am |
0 15 10 * *? * |
Daily 10:15am |
0 15 10 * *? 2005 |
Every day in 2005 10:15am |
0 * 14 * *? |
Every minute of every 2:00pm-3:00pm. |
0 0/5 14 * *? |
Every 5 minutes of 2:00pm-3:00pm per day, the end time is 2:55pm |
0 0/5 14,18 * *? |
Every 5 minutes of 2:00pm-3:00pm and 6:00pm-7:00pm per day, the end time is 2:55pm and 6:55pm |
0 0-5 14 * *? |
Every minute of 2:00pm-2:05pm every day |
0 10,44 14? 3 WED |
Every Wednesday of 2:10pm and 2:44pm in March. |
0 15 10? * Mon-fri |
10:15am from Monday to Friday |
0 15 10 15 *? |
10:15am on the 15th day of every month |
0 L *? |
10:15am of the last day of every month |
0 L-2 *? |
The 10:15am of the second day of every month. |
0 15 10? * 6 |
Every month, Friday 10:15am. |
0 15 10? * 6L |
The last Friday 10:15am of every month. |
0 15 10? * 6L 2002-2005 |
2002-2005 The last Friday 10:15am of every month. |
0 15 10? * 6#3 |
3rd Friday 10:15am per month. |
0 0 12 1/5 *? |
12:00PM of the first 5 days of each month (starting on the 1th day) |
0 11 11 11 11? |
11:11am of November 11 per year |
Quartz.net Learning Series (iii)---cron trigger