指定cron作业的任意开始和结束时间

编程入门 行业动态 更新时间:2024-10-13 16:18:15
本文介绍了指定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作业的任意开始和结束时间

本文发布于:2023-10-27 10:49:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533152.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   结束时间   cron

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!