What are the configuration rules for a Quartz cron expression?
The configuration rules for Quartz cron expressions are as follows:
- The requirement states that there should be 7 sections separated by 6 spaces: seconds, minutes, hours, date, month, day of the week, and year (optional).
- Each section can be represented by specific values, ranges, increments, or wildcards to indicate time.
- Specific values: a specific value can be specified, such as “0” representing 0 seconds, or “30” representing 30 seconds.
- Range: a range can be indicated using “-“, for example, “10-15” represents from 10 to 15.
- Increment: you can use “/” to indicate an increment value, for example, “0/5” means trigger every 5 seconds, starting from 0.
- “To represent any value, for example”
- Enumeration: multiple enumeration values can be represented using commas “,”. For example, “1,3,5” represents the values 1, 3, and 5.
- The string L can be used to represent the last value, for example “0 0 23 L * ?” means triggering at 23 hours on the last day of each month.
- String W: can be represented as “W” to indicate the nearest weekday, for example “0 0 0 ? * MON-FRI” triggers at 0:00 on Monday to Friday.
- String #: You can use “#” to indicate the day of the week in a month, for example, “0 0 0 ? * 6#3” represents triggering at 0 o’clock on the third Friday of every month.
- String C: Using “C” represents the last week of a month, for example, “0 0 0 ? * 6L” triggers at 0 o’clock on the last Friday of every month.
Please note that the above are just some common configuration rules briefly introduced, Quartz cron expressions have more complex configuration options and parameters. Specific configuration rules can be referred to according to actual needs in Quartz official documentation or related tutorials.