特定日期两周一次的石英cron表达 [英] Quartz cron expression for Once in a two week on particular day

查看:68
本文介绍了特定日期两周一次的石英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();

这篇关于特定日期两周一次的石英cron表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆