1

i want to run my Quartz job 4 times all day and i am using cron job to trigger my job and have provided value in xml. Please let me know the Quartz Expression so that i can trigger my job 4 times all day.

4

1 回答 1

5

That's pretty simple:

0 0 0/6 * * ?

This will fire at 0:00, 6:00, 12:00 and 18:00. If you want a different offset time, e.g. first invocation at 3:45:

0 45 3/6 * * ?

Check out JavaDoc of CronTrigger. But in your case a simple trigger will be... well, simpler:

trigger = newTrigger()
  .startNow()
  .withSchedule(simpleSchedule()
    .withIntervalInHours(6)
    .repeatForever())
  .build();

Note that the semantics aren't exactly the same. The former trigger reflects DST so it will always fire at the same wall clock time.

于 2012-08-28T15:36:02.643 回答