这个 cronExpression 正确吗?
我不知道下面的表达式是否正确:
<property name="cronExpression" value="0 0 12 2 * MON-FRI ?"/>
我尝试将触发器配置为每月的第二天触发,无论年份,在中午,并且一周中的某一天必须在星期一和星期五之间。
如果有人能帮助我,我将非常感激。提前致谢。
I don't know if the below expression is correct:
<property name="cronExpression" value="0 0 12 2 * MON-FRI ?"/>
I try to configure my trigger to fire every second day of every month, no matter the year, at noon, and the day of week has to be between Monday and Friday.
I'd really appreciate if someone could help me. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您的意思是“每隔一天(每隔一天),只要是周一至周五”。
根据 Quartz CronTrigger 教程:
因此,
1/2
表示“从该月的第一天开始每隔一天触发一次”。类似于0 0 12 1/2 * 的 cronExpression然后,MON-FRI *
应该接近您想要的内容。使用... 检查表明该表达式是有效的,
但是,使用以下命令进一步测试它:
... 抛出一个错误 。例外:
所以,似乎jhouse 是对的,而你不能用 cronExpression 做到这一点。
也许这样的方法可以作为解决方法:每 N 小时/天/周/月执行一次的 cron 触发器的 Quartz cron 表达式
I'm assuming you meant "every second day (every other day), as long as it's MON-FRI".
According to Quartz CronTrigger Tutorial:
So,
1/2
would mean "fire every second day starting on the first day of the month". A cronExpression like0 0 12 1/2 * MON-FRI *
should then be close to what you want. Checking with...says that the expression is valid.
However, testing it a little further with:
...throws an exception:
So, seems like jhouse is right and you just can't do that with a cronExpression.
Maybe something like this would work as a workaround: Quartz cron expression for cron triggers executed every Nth Hour/Day/Week/Month
您不能同时指定一个月中的某一天和一周中的某一天 - 不支持。
You cannot specify both a day of month and a day of week - it is not supported.