Quartz Cron expression :Run every 15 days ie twice in a month

六眼飞鱼酱① 提交于 2019-12-18 16:18:09

问题


I want to set the scheduler with a quartz cron expression which will trigger every 15 days ,for example 1st and 15th of every month.The 0 15 10 15 * ? is triggering only on 15th of every month.


回答1:


I have tested this and the following expression works fine

        "0 0 0 1,15 * ?"

the 1,15 statement fires triggers on 1st and 15th of every month at 00:00 hours. You can change the first three zeroes to fire them at a particular time you want.

the 1st zero -> seconds

the 2nd zero -> minutes

the 3rd zero -> hours




回答2:


The following also works fine, it executes your command on the 15th and the 30th at 02:00 AM of every month:

0 2 */15 * * <yourCommand>



回答3:


You just need to append 1 with a comma to your expression at 'Day of Month' block.

Rest is fine !

0 15 10 1,15 * ?

This will schedule to run every 1st and 15th day of the month and 10:15 am.




回答4:


0 0 1,15 * * “At 00:00 on day-of-month 1 and 15.”

0 0 1,15 1 * “At 00:00 on day-of-month 1 and 15 in January.”

0 0 1,15 1 6 “At 00:00 on day-of-month 1 and 15 and on Saturday in January.”



来源:https://stackoverflow.com/questions/22604362/quartz-cron-expression-run-every-15-days-ie-twice-in-a-month

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!