简体   繁体   中英

Quartz Scheduler Cron Expression with frequency as specific hour and minute

I am trying to build a cron expression using quartz in java. 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. - I used cron expression for this example as "0 */10 */1 * * ?". - But this job runs every 10th minute and not as 1 hour and 10 minutes.

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. The second */1 is redundant because it'll run anyway due to the first */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
  2. 02:10
  3. 03:10

If so, I think 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.

To achieve firing at a fixed rate every 1:10, ie

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

try the SimpleTrigger with a 1:10 interval.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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