简体   繁体   中英

quartz running only in even minutes

I am using quartz scheduler. While I am creating trigger for my job I am setting start time to it by using trigger.setStartTime() . Now my problem is in first fire time it runs to nearest even time. Let explain the above case with an example. My Trigger start time is: Thu Feb 14 13:53:00 IST 2013 . Recurrance cron expression is for every two minutes. So,the first fire time is Thu Feb 14 13:55:00 IST 2013 . But it is fired at Thu Feb 14 13:54:00 IST 2013 . From there it runs at every two minutes, ie 13:56:00,13:58:00 etc.. But I want to fire the job for every two minutes from start time of the trigger. Please help me to achieve that one.

Thanks in advance.

Which version of Quartz are you using and how are you building your triggers? If you're using version 2.0 or better, you should probably be using the DSL-like TriggerBuilder and SimpleTrigger/SimpleSchedule to build your triggers quickly and less error prone.

Quartz Tutorial Lesson 5

Your trigger would end up lokking something like this:

trigger = newTrigger()
    .withIdentity("my-trigger", "my-group")
    .withSchedule(simpleSchedule()
        .withIntervalInMinutes(2)
        .repeatForever())
    .build();

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