Quartz cron expression for Once in a two week on particular day

前端 未结 2 1089
我寻月下人不归
我寻月下人不归 2020-12-12 02:01

I am trying to create the Quartz cron expression which runs on every 2 week on given day

e.g.

Once in a every two week on Monday

and using the foll

相关标签:
2条回答
  • 2020-12-12 02:37

    This is something that is also very hard with the regular cron jobs, I think it cannot be achieved in a 'normal' cron expression.

    You could skip cron altogether and use the Trigger That Executes Every 2 Weeks

    trigger = newTrigger()
    .withIdentity("trigger3", "group1")
    .startAt(tomorrowAt(15, 0, 0)  // 15:00:00 tomorrow
    .withSchedule(calendarIntervalSchedule()
            .withIntervalInWeeks(2)) // interval is set in calendar weeks
    .build();
    
    0 讨论(0)
  • 2020-12-12 02:42

    This is a limitation of cron-like expressions. The best solution that comes to my mind is to create two triggers for that job, instead of trying to use it only with the cron expression.

    0 讨论(0)
提交回复
热议问题