Search code examples
scheduled-tasksquartz-schedulerschedulerjob-schedulingquartz

How to schedule a Job using Quartz to run at multiple but fixed times in a day


Say i have job which needs to be executed at fixed times in a day like below, "05:00, 06:10, 07:30, 08:15, 09:05, 10:35"

How could i build a Trigger for this in Quartz ?


Solution

  • I couldnt find the way to achieve this out-of-the-box.

    I see two ways to solve your problem:

    1. Multiple triggers (recommended).

    The most obvious and easy way to set the unusual scheduling for you job is to combine several triggers. Quartz allows to set as much triggers as you want for single JobDetail.

    2. Implement your own trigger.

    It is more complicated way, applicable only if you must use only one trigger. You could implement org.quartz.Trigger interface or any subinterfaces to set yourown rules.