Search code examples
javacronquartz-schedulerjobs

Schedule Job for specific hours interval using Quartz


My Quartz cron expression is this:

50 * 10-11 * * ?

From what I understand this means:

Run the job every 50 second of every minute within hours 10 to 11 (am) for every week/month and year.

The problem is that the job is running even after hour 11AM..

I tried

50 * 10-11 * * *

but this way I get the exception:

support for specifying both a day-of-week and a day-of-month parameter is not implemented

Solution

  • I found how it works. 10-11 actually means that the job will run for 2 hours and not for one. It will run till 11:59:59. The same thing is even for minutes; if I write:

    50 0-10 10-11 * * ?

    The job will run on second 50 for 11 times(0-10) for each hour (10 and 11).

    Hope this will help someone like me :)