Crontriggers is often more useful than simpletrigger. If you need to follow the calendar concept, instead of the time interval specified by simpletrigger, the recurrence of the launch work schedule.
Crontrigger: You can specify the trigger schedule, for example, "Midday every Friday", "every working day", or even "and every five minutes every Monday morning, ".
Even so, like simpletrigger, the specified start time of the crontrigger takes effect, and the end time of the specified schedule should be stopped (optional.
Cron expressions
The cron expression is used to configure the crontrigger instance. The cron expression is a string. It is actually a timeline of seven subexpressions that describe individual details. These subexpressions are separated spaces, representing:
1.Seconds
2.Minutes
3.Hours
4.Day-of-month
5.Month
6.Day-of-week
7.Year (Optional Fields)
Example: "0 0 12? * Wed "is executed at every Wednesday,
Individual subexpressions can include a range, for example, in the previous example ("wed") can be replaced with "MON-FRI", "mon, wed, Fri" or even "MON-WED, sat ".
"*" Indicates the entire time period.
Each field has a set of valid values, such
Seconds(Seconds): The value can be 0-59,
Minutes (Points): The value can be 0-59,
Hours (Time): The value can be 0-23,
Day-of-month (Day): You can use any one of the numbers 1-31, but pay attention to some special months.
Month (Month): it can be expressed by 0-11 or by the string "Jan, Feb, MAR, APR, May, Jun, Jul, Aug, SEP, Oct, Nov and Dec ".
Day-of-week (Weekly):It can be represented by numbers 1-7 (1 = Sunday) or by string "Sun, Mon, Tue, wed, Thu, Fri and sat"
"/": It is a special unit. It indicates "every". For example, "0/15" indicates execution every 15 minutes, and "0" indicates execution starting from "0, "3/20" indicates execution every 20 minutes, and "3" indicates execution starting from 3rd minutes.
"?" : Indicates a day of the month or a day of the week.
"L" indicates the last day of a month or every week, or the last day of a month. For example, "6l" indicates "the last Friday of a month"
"W": indicates the last workday. For example, "15 W" is placed on the Day-of-month field and indicates "the most recent workday to January 1, 15th day of this month"
"#": Specifies the "nth business day of each month", for example, on the day of a week (day-of-week) if this field is "6 #3" or "Fri #3", it indicates "the third Friday of every month"
1) cron expression format: second minute hour day month week year (optional ).
Special characters allowed by Field Names
Seconds 0-59 ,-*/
0-59 ,-*/
Hour 0-23 ,-*/
1-31 ,-*? /L W C
Month 1-12 or JAN-DEC ,-*/
What is the week 1-7 or sun-Sat ,-*? /L c #
Year (optional) empty, 1970-2099 ,-*/
"?" Character: uncertain value
"," Character: specifies several values
-Character: Specifies the range of a value.
"/" Character: Specifies the increase range of a value. N/m indicates that M is increased each time starting from N.
"L" character: Used in the day to represent the last day of the month, used in the week to represent the last day of the month x
"W" character: Specifies the business day closest to the given date (Monday to Friday)
"#" Character: indicates the week X of the month. 6 #3 indicates the first Friday of the month
2) cron expression example:
Run the command once every 5 seconds: */5 ****?
Run Once every 1 minute: 0 */1 ***?
Execute once at every day: 0 0 23 **?
Run the command once every morning: 0 0 1 **?
Execute once at on the first day of every month: 0 0 1 *?
Run Once at on the last day of each month: 0 0 23 L *?
Once every Sunday at AM: 0 0 1? * L
Execute at 26, 29, and 33: 0, 33 ***?
Every day at, and: 0 0 **?
Quartz cron expression