Quartz CRON 触发器未按预期触发
我有一个在 Spring 2.5.6-SEC01 中运行的简单石英触发器。
触发器定义如下所示:
<bean id="AdvicesCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="AdvicesQuartzJob"/>
<property name="cronExpression" value="0 20/15 * * * ?"/>
</bean>
这是我的调度程序工厂:
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="AdvicesCronTrigger"/>
</list>
</property>
</bean>
我已阅读 此文档 关于从 Quartz 触发 CRON 触发器。这是摘录:
CronTrigger 示例 1 - 表达式 创建一个简单触发的触发器 每 5 分钟一次
“0 0/5 * * * ?”
今天我在 9:40 解雇了我的程序。这是我的执行输出:
编辑: Bobby 的赞赏是正确的。我更新了我的执行日志:
2010-02-11 09:50:00,000 信息 - 开始
2010-02-11 10:20:00,000 信息 - 开始
2010-02-11 10:35:00,000 信息 - 开始
2010-02-11 10:50:00,000 信息 - 开始
2010-02-11 11:20:00,000 信息 - 开始
2010-02-11 11:35:00,000 信息 - 开始
我预计该触发器将被触发
9:50
10:05
10:20
10:35
...
如何实现这一点?使用哪个 CRON 表达式?
I have a simple quartz trigger running in Spring 2.5.6-SEC01.
Trigger definition looks like this:
<bean id="AdvicesCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="AdvicesQuartzJob"/>
<property name="cronExpression" value="0 20/15 * * * ?"/>
</bean>
This is my scheduler factory:
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="AdvicesCronTrigger"/>
</list>
</property>
</bean>
I've read this documentation about firing CRON triggers from Quartz. This is an excerpt:
CronTrigger Example 1 - an expression
to create a trigger that simply fires
every 5 minutes"0 0/5 * * * ?"
Today I fired my program at 9:40. This is my execution output:
Edit: Bobby is right in his appreciation. I've updatted my execution log:
2010-02-11 09:50:00,000 INFO - START
2010-02-11 10:20:00,000 INFO - START
2010-02-11 10:35:00,000 INFO - START
2010-02-11 10:50:00,000 INFO - START
2010-02-11 11:20:00,000 INFO - START
2010-02-11 11:35:00,000 INFO - START
I expected that this trigger will be fired at
9:50
10:05
10:20
10:35
...
How to accomplish this? Which CRON expression use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cron 表达式的
20/15
部分表示每小时第 20 分钟后每 15 分钟一次。这意味着比赛总是在第 20 分钟开始。我从未测试过它,但也许像这样的表达式就是您正在寻找的:
0 */15 * * * ?
The
20/15
part of the cron expression means every 15 minutes after the 20'th minute of the hour. This means that it will always start at the 20'th minute.I have never tested it but maybe an expression like this one would be what you are searching for :
0 */15 * * * ?
不是给您一个不相关的答案,但有时使用某些服务而不是尝试自己做是有意义的:)看看 http://www.cronservice.co.uk/new/, http://scheduler.codeeffects.com 或 http://www.webbasedcron.com/
Not to give you a non-related answer, but sometimes it makes sense to use some services instead of trying to do it yourself :) Take a look at http://www.cronservice.co.uk/new/, http://scheduler.codeeffects.com, or http://www.webbasedcron.com/