Cron 触发时间为 12:04 至 14:25
是否可以为必须从 12:04 到 14:25 每天每分钟触发的触发器编写 cron 表达式?
Is it possible to write cron expression for trigger that must fire every day and every minute from 12:04 to 14:25?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为最短的解决方案(使用 cron)是这 3 行,
它们定义了每小时的触发范围。
I think the shortest solution (using cron) are these 3 lines
They define the trigger ranges for each hour.
您必须设置 3 个 diff cron 作业:
You'll have to set 3 diff cron jobs:
您标记了quartz,因此这里是取自文档的示例 http://quartz .sourceforge.net/javadoc/org/quartz/CronTrigger.html
0 * 12-14 * * ?
每天 12:00 到 14:59 之间每分钟触发一次。从示例来看
“0 0/5 14,18 * * ?”从下午 2 点开始到下午 2:55 结束,每 5 分钟触发一次,并且每天从下午 6 点开始到下午 6:55 结束,每 5 分钟触发一次
在我链接到的网页中,您也许可以做一些事情就像0 4-59,0-59,0-25 12,13,14 * * ?
但我不确定这是否有效,因为它看起来有点可疑,而且文档没有如果你这样写,请说明如何解释分钟/小时。如果不起作用,您必须定义三个触发器:
You tagged quartz so here is an example taken from the docs at http://quartz.sourceforge.net/javadoc/org/quartz/CronTrigger.html
0 * 12-14 * * ?
would fire every minute every day between 12:00 and 14:59.Judging by the example
"0 0/5 14,18 * * ?" Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day
in the web page i linked to, you may be able to do something like0 4-59,0-59,0-25 12,13,14 * * ?
but I'm not sure that would work because it looks a bit dubious, and the docs don't say how the minutes/hours are interpreted if you write it like that. If it doesn't work, you have to define three triggers: