简体   繁体   English

Quartz Scheduler Cron Expression,频率为特定的小时和分钟

[英]Quartz Scheduler Cron Expression with frequency as specific hour and minute

I am trying to build a cron expression using quartz in java. 我试图在Java中使用石英来构建cron表达式。 I get two parameters as hour and minute with which I have to schedule a job every hour and minute. 我得到两个参数,即小时和分钟,必须每小时和每分钟计划一次作业。 Till now I have tried this : Example 1:- Schedule job to run every 1 hour 10 minutes. 到目前为止,我已经尝试过: 示例1:- 安排作业每1小时10分钟运行一次。 - I used cron expression for this example as "0 */10 */1 * * ?". -在本例中,我使用cron表达式为“ 0 * / 10 * / 1 * *?”。 - But this job runs every 10th minute and not as 1 hour and 10 minutes. -但是此作业每10分钟运行一次,而不是1小时10分钟。

Can anyone help me understand why this expression is not working ? 谁能帮助我了解为什么此表达式不起作用? Thanks in advance. 提前致谢。

Your cron expression will run every 10 minutes because that's what the first */10 means. 您的cron表达式将每10分钟运行一次,因为这就是第一个*/10含义。 The second */1 is redundant because it'll run anyway due to the first */10 . 第二个*/1是多余的,因为第一个*/10仍然可以运行。

It's not clear to me what you're trying to do - recurring schedules can be tricky to express clearly, so I tend to write down a few examples and work from there. 我不清楚您要做什么-重复的时间表很难清楚地表达出来,因此我倾向于写下一些示例并从那里开始工作。

Are you trying to get a pattern like: 您是否正在尝试获得类似以下的模式:

  1. 01:10 01:10
  2. 02:10 02:10
  3. 03:10 03:10

If so, I think 0 10 * * * ? 如果是这样,我认为是0 10 * * * ? should do the job. 应该做的工作。 The documentation I used to understand the expression is at http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06.html and I also found http://www.cronmaker.com/ to be really helpful for sanity checking the expression - it'll work out the next few trigger times for you. 我用来理解该表达式的文档位于http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06.html ,我也找到了http://www.cronmaker .com /确实有助于检查表达式的准确性-它将为您确定接下来的几个触发时间。

To achieve firing at a fixed rate every 1:10, ie 为了以每1:10的固定速率发射,即

  1. 1:10 1:10
  2. 2:20 2:20
  3. 3:30 3:30

try the SimpleTrigger with a 1:10 interval. 尝试以1:10的间隔进行SimpleTrigger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM