Search code examples
javacronquartz-schedulercronexpression

Quartz | Cron expression not working as expected


I'm trying to build up a cron expression that will trigger in every minute starting from a given hourly range.

My expression would be:

0 0/1 12/10-14 * 1-5 ?

I'm expecting this to work as, starting from 12.04 AM to 02.00PM trigger at every minute.

But when I start the application it just trigger from next minute of the hour 12.01 despite the range or starting minute at 12.10.


Solution

  • There is mistake in your cron expression.

    0 {start minute}/{every minute} [from hour- to hour] * 1-5 ?
    

    So the answer is

    It will start at 12:00 AM - 01 : 00 AM

    0 4/1 0-1 * 1-5 ?
    

    It will start at 12:00 AM - 02 : 00 PM

    0 4/1 0-14 * 1-5 ?
    

    It will start at 12:00 AM - 02 : 00 PM Every Day

    0 4/1 0-14 * * ?