tags:

views:

335

answers:

1

Hi,

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?

Regards Sandeep Jindal

A: 

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);
Nikolaus Gradwohl
Thanks that would work, but thats not very smart, is not it. I am working on huge application which onstartup will require the CronJob to be started. I dont want to change the cron expression every time i am going to start my application. Do we have some alter solution please?
Sandeep Jindal
I edited my post and added a "smarter" version :-)
Nikolaus Gradwohl
i fear that the smarter version is not configurable through spring.
Sandeep Jindal