Cron expression every 50 seconds in Quartz

大憨熊 提交于 2019-12-05 19:08:38

问题


I'm running my Jobs using Quartz with a cron expression every 50 seconds:

Cron_Expression = "0/50 * * * * ?"

What happens is that my job runs at the seconds: 50, 60, 50, 60,... and not every 50 seconds! and does not run at the second "0".

What is the right cron expression every 50 seconds starting at 0?


回答1:


The '/' syntax specifies the increment during the period and not a repeat interval. Admittedly a subtle and confusing difference.

In this case there is only one available increment (50 seconds) during the 1 minute period. The first number specifies the value to start with, in this case 0. Specifying '*' before the '/' is equivalent to specifying 0. So the job will only fire on the minute (0 and 60 are interchangeable) and at 50 seconds.

If the period can be divided by multiple increments, eg 0/10 then it will fire for each at each of those times, eg at 10, 20, 30 etc seconds.

If you want a job to trigger at a regular interval then you can use a Quartz SimpleTrigger with a repeatInterval specified.



来源:https://stackoverflow.com/questions/15458254/cron-expression-every-50-seconds-in-quartz

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