特定日期两周一次的石英cron表达
问题描述:
我正在尝试创建Quartz cron表达式,该表达式在给定的日期每2周运行一次
I am trying to create the Quartz cron expression which runs on every 2 week on given day
例如
星期一每两周一次
并使用以下表达式
0 0 6 ? * 1#2,1#4
但是不知何故我遇到了错误
but somehow I am getting following error
未支持指定多个第n"天.
Support for specifying multiple "nth" days is not implemented.
答
使用常规cron作业也很难做到这一点,我认为无法通过常规" cron表达式来实现.
This is something that is also very hard with the regular cron jobs, I think it cannot be achieved in a 'normal' cron expression.
您可以完全跳过cron并使用每两周执行一次的触发
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();