Quartz cron - 如果月份中的某一天不存在怎么办?
我正在尝试为石英调度程序编写一个简单的 cron 表达式。我希望该作业在每月第 30 天凌晨 3 点运行。
0 0 3 30 JAN-DEC ? *
我想知道二月会发生什么?作业会运行还是不会运行?
我不是在寻找每月最后一天的解决方案,我需要用户选择作业运行的日期(最好是所有月份一次)。
I'm trying to write a simple cron expression for quartz scheduler. I want the job to run every month on day 30 at 3am.
0 0 3 30 JAN-DEC ? *
I wonder what happens for the month of February? Will the job run or not run?
I'm not looking for a last day of month solution, I need the user to select the day of month when the job will run (ideally once for all months).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
L(“最后”)- 在允许使用的两个字段中具有不同的含义。例如,日期字段中的值“L”表示“该月的最后一天” - 对于非闰年,一月为第 31 天,二月为第 28 天。如果单独用于星期几字段,则它仅表示“7”或“SAT”。但如果在星期几字段中使用另一个值之后,则表示“该月的最后 xxx 天” - 例如“6L”表示“该月的最后一个星期五”。使用“L”选项时,重要的是不要指定列表或值范围,因为您会得到令人困惑的结果。
您可以使用它来指定,而不是直接在玉米作业中指定 30。
http://www.quartz-scheduler.org/documentation/quartz -1.x/tutorials/crontrigger
检查特殊字符。
谢谢。
L ("last") - has different meaning in each of the two fields in which it is allowed. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
You can use this to specify instead of specifying 30 in your corn job directly.
http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
Check for Special characters.
Thanks.
它不会运行。如果您希望它在 2 月的 28 日运行,则必须为一个月中的每种情况创建多个 CronExpressions,并为每个触发器创建一个触发器,然后将所有触发器添加到所需的作业中。
这就是我所做的:
CronExpressions 创建:
触发器创建:
It won't run. If you want it to run in the 28th in case of February, you have to create multiple CronExpressions for each case of days in month, and a trigger for each one, and then add all the triggers to your required Job.
This is what I have done:
CronExpressions creation:
Trigger creation:
检查简单代码
对于此代码,输出将是:
玩弄参数,你可以找到答案
check simple code
For this code the output will be:
playing with arguments you can find answers
下面的代码计算每月最后一天的下一次火灾日期
The below code calculates the next fire date for the last day of every month