Search code examples
javaquartz-scheduler

Start quartz trigger next day at specified time


How can i pause my quartz trigger and start it next day at its specified start time ? For eg. My cron expression is * 0/20 15-00 * * ? So when i pause my trigger it should start next day at 15:00.


Solution

  • In general, pausing a trigger does not affect its next fire time.

    I.e. if you have a CronTrigger which runs every day at 6 o'clock, and you pausing that trigger before its firing for that day, it is not firing.

    But since the next fire time is not changed, that trigger should immediatly fire or execute its MisfireInstruction after unpausing it again. Whether the trigger is fired or its MisfireInstruction is executed depends on the MisfireThreshold.

    For the case of a CronTrigger you could just adapt the nextFireTime before unpausing the CronTrigger. ( see CronTrigger.setNextFireTime() )