Search code examples
javacronquartz

How to run Quarz Cron Job between specific time?


I want to execute cron job between specific time. i.e. Cron job should execute every 15 minutes between 7:03 to 21:04?

I can manage between 7 to 9 but can't schedule between 7:03 to 9:05.


Solution

  • After understanding your requirement clearly, AFAIK, you need two schedulers:

    First Scheduler (runs between hours 07:00 to 21:00):

    Cron expression should be like 0 3/15 7-20 * * *

    0 - seconds

    3/15 - runs at 3rd, 18th, 33rd, 48th minutes of each hour

    7-20 - starting from 07AM to 08PM (included)

    Second Scheduler (runs ONLY at 21:04):

    Cron expression should be like 0 4 21 * * * (which runs ONLY at 21:04)