29
votes

I am using Quartz Scheduler using Spring. I want to configure the same with following schedule:

Run Job Every 10 minutes starting NOW

I am using following expression for the same.

0 */10 * * * ?

I thought * in the minutes field would make it run the first minute, but it does not do that way. It runs the first 10th minutes from now and then every 10 minutes afterwards. Can anybody please suggest me the reason for this behavior and the solution to my problem also?

4

4 Answers

12
votes

check the minute your at now and add them as a list to your crontrigger. if you start the trigger at minute 12 for example add

0 2,12,22,32,42,52 * * * ? 

as your cron expression

Edit:

Another solution would be to define a simpletrigger that repeats every ten minutes

SimpleTrigger trigger = new SimpleTrigger("myTrigger",
                                            null,
                                            new Date(),
                                            null,
                                            SimpleTrigger.REPEAT_INDEFINITELY,
                                            10L * 60L * 1000L);
16
votes
2
votes

You can use something like

0 1-59/10 * * * ?

That will trigger the job at any minute and 10 minutes after that. I didn't try it but it looks right. :)

-5
votes
*/10 * * * *

Every 10 minutes starting from the moment you create the cron job, wether you prefer (user crontab, /etc/cron.d/, ...).