指定cron作业的任意开始和结束时间 [英] Specify arbitrary start and end times for cron job

查看:2413
本文介绍了指定cron作业的任意开始和结束时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Quartz Cron,是否可以指定对应于以下的cronexpression:

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

每6分钟运行一次,从9开始: c>

我试图写cronexpression 0 12-37 / 6 9- 17? * * ,但这只会每小时运行一次。我还了解 cronexpression 0/6 9-17? * * 对应于在上午9点至下午5点之间每6分钟运行

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.

但是有什么方法来约束cronexpression的开始和结束分钟吗?更一般来说,我可以指定一个任意的开始和结束时间与正在运行每个 n 时间间隔的问题的作业吗?

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?

推荐答案

您可以使用3个cron字符串:

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.

这篇关于指定cron作业的任意开始和结束时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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