Specify arbitrary start and end times for cron job

时间秒杀一切 提交于 2019-12-07 01:42:36

问题


For Quartz Cron, is it possible at all to specify a cronexpression that corresponds to:

Run every 6 minutes, starting from 9:12 AM until 5:37 PM.

I attempted to write the cronexpression 0 12-37/6 9-17 ? * * but this does only runs once an hour. I also understand that the cronexpression 0 /6 9-17 ? * * corresponds to Run every 6 minutes between the hours of 9 AM and 5 PM.

But is there any way to constrain the starting and ending minutes on that cronexpression? More generally, can I specify an arbitrary start and end time with the job in question running every n intervals of time?


回答1:


You can do it with 3 cron strings:

0 12-59/6 9 * * *
0 /6 10-16 * * *
0 0-37/6 17 * * *

Give them all the same task to run.



来源:https://stackoverflow.com/questions/16949449/specify-arbitrary-start-and-end-times-for-cron-job

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