Quartz cron Expression
Special characters allowed for field allowed values
Seconds 0-59,-*/
Sub 0-59,-*/
Hours 0-23,-*/
Date 1-31,-*? /L W C
Month 1-12 or JAN-DEC,-*/
Week 1-7 or Sun-sat,-*? /L C #
Year (optional) leave blank, 1970-2099,-*/
The "*" character is used to specify all values. such as: "*" in the field of the minute to indicate "per minute."
“?” Characters are used only in date and weekday fields. It is used to specify a "non-explicit value". It is useful when you need to specify something by one of these two fields. Look at the example below and you'll understand.
The date in the month and the date in the day of the week are mutually exclusive when the two elements should be set by a question mark (?). To indicate that you do not want to set that field.
The "-" character is used to specify a range. For example: "10-12" in the hour field means "10 points, 11 points, 12 points".
The "," character is used to specify a different value. such as: "Mon,wed,fri" in the field of the week to say "Monday, Wednesday, Friday."
The "/" character is used to specify increments. such as: "0/15" in the second field means no minutes of 0,15,30 and 45 seconds. "5/15" in the minute field represents the 5,20,35 and 50 of the hour. The symbol "*" in front of "/" (eg: */10) is equivalent to 0 in front of "/" (for example: 0/10). Remember the essence: each numeric field of an expression is a collection with the largest and smallest values, such as: The collection of second and minute fields is 0-59, the Date field is 1-31, and the Month field is 1-12. The character "/" helps you to take a corresponding value in each character field. such as: "7/6" in the month domain only when the July will be triggered, does not mean that every June.
L is the ellipsis of ' last ' to represent the Day-of-month and Day-of-week fields, but they differ in two fields, such as the last day of one months represented in the Day-of-month field. If the Day-of-week field represents ' 7 ' or ' SAT ', if preceded by a number in the Day-of-week field, it represents the last days of one months, e.g. ' 6L ' represents the last Friday of one months.
The character "W" only allows date fields to appear. This character is used for the last working day of the specified date. For example, if you write "15W" in the Date field, it means: the most recent working day of 15th this month. So, if number 15th is Saturday, then the task will be triggered at number 14th. If the 15 good is Sunday, then the task will be triggered in Monday, the number 16th. If you fill in the Date field "1W" even if the number 1th is Saturday, then the task will only be in the next Monday, that is, the number 3rd trigger, the "W" character specified in the last working day is not able to cross the month. The character "W" can only be used with a single numeric value and cannot be a number field, such as: 1-15w is wrong.
"L" and "W" can be combined in a date field, and LW represents the working day of the last week of the month.
The character "#" is only allowed to appear in the day of the week field. This character is used to specify a certain day of the month. For example: "6#3" means Friday of the third week of this month (6 for Friday, 3 for the third week). "2#1" represents the first week of this month in Monday. "4#5" means Wednesday of the fifth week.
The character "C" is allowed to appear in the Date field and the Weekday field. This character relies on a specified "calendar". This means that the value of this expression depends on the results of the relevant "calendar", and if there is no calendar association, it is equivalent to all included calendars. For example: the Date field is "5C" for the first day of the associated calendar, or 5 days after the first day of the month. The week field is "1C" for the first day of the associated calendar, or 1 days after the first day of the week, that is, the day after Sunday (Monday).
An example of an expression:
"0 0 12 * *?" Triggered 12 o'clock noon every day
"0 15 10?" * * "trigger 10:15 every day"
"0 15 10 * *?" Triggered 10:15 daily
"0 15 10 * *?" * "10:15 per day" trigger
"0 15 10 * *?" 2005 "2005-year daily 10:15 Trigger
"0 * 14 * *?" Triggers every 1 minutes from 2 o'clock in the afternoon to 2:59 daily
"0 0/5 14 * *?" Triggers every 5 minutes from 2 o'clock in the afternoon to 2:55 daily
"0 0/5 14,18 * *?" Every 5 minutes from 2 o'clock in the afternoon to 2:55 daily and from 6 o'clock in the afternoon to 6:55
"0 0-5 14 * *?" Triggers every 1 minutes from 2 o'clock in the afternoon to 2:05 daily
"0 10,44 14?" 3 WED "2:10 and 2:44 triggers in Wednesday of every March
"0 15 10?" * Mon-fri "Monday to Friday 10:15 trigger
"0 15 10 15 *?" 15th 10:15 per month, triggered
"0 L *?" 10:15 trigger on the last day of the month
"0 15 10?" * 6L "Last month of Friday 10:15 Trigger
"0 15 10?" * 6L 2002-2005 "2002 to 2005 the last of the monthly Friday 10:15 trigger
"0 15 10?" * 6#3 "Monthly third Friday 10:15 trigger
0 6 * * * 6 o ' Day in the morning
0 */2 * * * every two hours
0 23-7/2,8 * * * 11 o'clock to 8 a.m. every two hours in the morning and eight in the morning.
0 11 4 * 1-3 4th for each month and Monday to Friday Monday to three in the morning.
0 4 1 1 * January 1 morning, 4.
JAVA Quartz cron expression detailed date expression