Friends, I am using quartz scheduler for running a task every 5 minutes starting when application deployed & running continuously so i have written code as:
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sche = sf.getScheduler();
JobDetail job = newJob(RomeJob.class).withIdentity("Id1", "Rome").build();
CronTrigger trigger = newTrigger().withIdentity("Id1Trigger", "Rome").withSchedule(cronSchedule("0 0/5 * * * ?"))
.build();
sche.scheduleJob(job, trigger);
sche.start();
But its working sometime sometimes not. Please tell me whether i am missing something here?
Instead of
0 0/5 * * * ?
use
0 */5 * * * *
Edit: This results in your task being run at 0 seconds of every minute that is divisible by 5.
Edit 2: 0/5
means only the minutes 0 and 5.