0

I've one Job running Every First Monday. I am using CronTrigger for that. My cron expression for existing job is as below.

0 0 0 ? * MON#1

Now, I want to change it to run on every alternate Monday of every Month. Means on

  • 1st Monday,
  • 3rd Monday,
  • 5th Monday like that.

my class for cron scheduler is

org.springframework.scheduling.quartz.CronTriggerBean
Taher A. Ghaleb
  • 5,120
  • 5
  • 31
  • 44
  • may be duplicate with https://stackoverflow.com/questions/16935701/generate-quartz-cron-expression-every-2nd-monday-friday – elbraulio Dec 04 '18 at 21:42
  • @elbraulio Is it not possible to generate one cron expression for the above requirement? I don't want on friday only on alternate monday and in your link it is for 2nd monday. – Jignesh Savaliya Dec 05 '18 at 08:38
  • in your case would be `0 0 0 ? * 2#1 *` and `0 0 0 ? * 2#3 *`. I use [this tool](https://www.freeformatter.com/cron-expression-generator-quartz.html) to create expressions – elbraulio Dec 05 '18 at 11:15
  • @elbraulio so, as per your suggesstion, 3 cron Triggers I need to create which is not good. I needed only one expression which fulfill this scenario. is it possible or not? – Jignesh Savaliya Dec 05 '18 at 11:26
  • it is not possible with an expression. You can use triggers as [this post recommends](https://stackoverflow.com/questions/36641783/quartz-cron-expression-for-once-in-a-two-week-on-particular-day) – elbraulio Dec 05 '18 at 13:50
  • check this [answer](https://stackoverflow.com/a/68191988/4482269), you might need to adjust the day – Wolfack Jun 30 '21 at 10:56
  • Does this answer your question? [Using Crontab to schedule a task every other friday](https://stackoverflow.com/questions/32260918/using-crontab-to-schedule-a-task-every-other-friday) – Wolfack Jun 30 '21 at 10:56

0 Answers0