Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

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

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 following expression

0 0 6 ? * 1#2,1#4

but somehow I am getting following error

Support for specifying multiple "nth" days is not implemented.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...