我正在使用石英调度程序来安排我的工作。我用过CronTrigger。但问题是触发器被触发了一次。这是我设置cron scheduler的代码..
SchedulerFactory schFactory = new StdSchedulerFactory();
Scheduler sched = null;
CronTrigger cronTrigger = null;
try {
sched = schFactory.getScheduler();
JobDetail jobDetail = new JobDetail("job1", "group1",SchedulerPBGC.class);
String cronTimerStr = "* 16 15 * * ? *";
LOG.warn("CRON TRIGGER FORMAT FOR PROCESSING PB GC DATA:"+cronTimerStr);
cronTrigger = new CronTrigger("SchedTrigger", "Group1", cronTimerStr);
sched.scheduleJob(jobDetail, cronTrigger);
sched.start();
LOG.warn("SCHEDULER REGISTERED FOR PROCESSING PB GC DATA : TIME :"+cronTimerStr);
} catch (SchedulerException se) {
LOG.error("SchedulerException Message::"+se.getLocalizedMessage());
}
这里我的调度程序执行了10次作业...在这里你可以看到日志..
2012-06-20 15:16:50,001 DefaultQuartzScheduler_Worker-1 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:50,001 DefaultQuartzScheduler_Worker-1 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:50,001 DefaultQuartzScheduler_Worker-1 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:51,001 DefaultQuartzScheduler_Worker-2 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:51,001 DefaultQuartzScheduler_Worker-2 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:51,001 DefaultQuartzScheduler_Worker-2 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:52,001 DefaultQuartzScheduler_Worker-3 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:52,001 DefaultQuartzScheduler_Worker-3 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:52,001 DefaultQuartzScheduler_Worker-3 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:53,001 DefaultQuartzScheduler_Worker-4 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:53,001 DefaultQuartzScheduler_Worker-4 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:53,001 DefaultQuartzScheduler_Worker-4 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:54,001 DefaultQuartzScheduler_Worker-5 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:54,001 DefaultQuartzScheduler_Worker-5 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:54,001 DefaultQuartzScheduler_Worker-5 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:55,001 DefaultQuartzScheduler_Worker-6 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:55,001 DefaultQuartzScheduler_Worker-6 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:55,001 DefaultQuartzScheduler_Worker-6 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:56,001 DefaultQuartzScheduler_Worker-7 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:56,001 DefaultQuartzScheduler_Worker-7 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:56,001 DefaultQuartzScheduler_Worker-7 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:57,001 DefaultQuartzScheduler_Worker-8 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:57,001 DefaultQuartzScheduler_Worker-8 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:57,001 DefaultQuartzScheduler_Worker-8 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:58,001 DefaultQuartzScheduler_Worker-9 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:58,001 DefaultQuartzScheduler_Worker-9 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:58,001 DefaultQuartzScheduler_Worker-9 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED-----------------------
2012-06-20 15:16:59,001 DefaultQuartzScheduler_Worker-10 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION STARTED-----------------------
2012-06-20 15:16:59,001 DefaultQuartzScheduler_Worker-10 WARN test.SchedulerPBGC - The value of NO_OF_BEFORE_DAY_TO_RUN must be less then zero ..to start the scheduler
2012-06-20 15:16:59,001 DefaultQuartzScheduler_Worker-10 WARN test.SchedulerPBGC - ----------PB GC SCHEDULER EXECUTION COMPLETED--------------------
如何将CronTimer迭代器设置为1?或者如何停止调度程序多次执行作业。
有什么建议吗? 谢谢, Gunjan Shah。
答案 0 :(得分:2)
我得到了解决方案..
我使用的cron语法是:String cronTimerStr =“* 16 15 * *?*”;
在15:16时,Quartz将每秒初始化所有可能的工人。因此,在一分钟内(@ 16分钟和60秒),它将初始化最多60个线程。
我将第二个参数设置为零。 所以新语法是“0 16 15 * *?*”。
现在工作正常。
谢谢, Gunjan Shah。