Cron Expression is set to,
Seconds | Minutes | Hours | Day Of Month | Month | Day Of Week | Year |
0 | 0 | 0 | ? | * | * |
The documentation we can use used for the Quartz cronTrigger format can be found here:
http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/tutorials/tutorial-lesson-06.html#TutorialLesson6-ExampleCronExpressions
and we use this page to construct the expressions needed:
https://www.freeformatter.com/cron-expression-generator-quartz.html
It is very good and will let you select the options you want and generate an expression from it, or put in an expression and show you what schedule it represents.
1) Every 2 minutes starting at 0 minutes past midnight: 0 */2 * ? * *
2) Every weekday, every 4 hours starting at midnight: 0 0 */4 ? * MON-FRI *
3) First Monday every month at midnight: 0 0 0 ? * 2#1 *
4) On the 2nd, 3rd, 4th, and 5th Monday of every month:
This one is a little trickier as Quartz CronTriggers doesn't support multiple 'Nth Monday of the month' triggers so you'll actually need to set up 4 different schedules using:0 0 0 ? * 2#2 *
0 0 0 ? * 2#3 *
0 0 0 ? * 2#4 *
0 0 0 ? * 2#5 *
If there isn't a 5th Monday in the current month the last one will not trigger until the next month that has 5 Mondays.
Comments
0 comments
Please sign in to leave a comment.