问题描述
我使用Quartz运行我的作业,每隔50秒使用一个cron表达式:
I'm running my Jobs using Quartz with a cron expression every 50 seconds:
Cron_Expression = "0/50 * * * * ?"
我的工作在几秒钟内运行: 50,60,50,60 ,... 而不是每50秒!并且不会在第二个0运行。
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".
从0开始,每50秒正确的cron表达式是什么?
What is the right cron expression every 50 seconds starting at 0?
推荐答案
'/'语法指定期间的增量而不是重复间隔。不可否认,这是一个微妙而混乱的区别。
The '/' syntax specifies the increment during the period and not a repeat interval. Admittedly a subtle and confusing difference.
在这种情况下,1分钟内只有一个可用的增量(50秒)。第一个数字指定要开始的值,在这种情况下为0.在'/'之前指定'*'相当于指定0.因此作业将仅在分钟(0和60可互换)和50秒时触发。
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.
如果周期可以除以多个增量,例如0/10,那么每次都会触发每个周期,例如10,20,30等秒。
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.
如果你想让一个工作定期触发,那么你可以使用Quartz SimpleTrigger
code> repeatInterval 指定。
If you want a job to trigger at a regular interval then you can use a Quartz SimpleTrigger
with a repeatInterval
specified.
这篇关于在Quartz中每50秒Cron表达一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!