Search code examples
cronquartz-schedulerquartz.netcronexpression

Cron expression for Quartz scheduler to fire every 5 minutes from 09:00 to 09:45


I assumed that a cron expression that triggers every 5 minutes from 09:00 to 09:45 should be as simple as 0 0-45/5 9 * * ?. However, using this as a <cron-expression> in a Quartz.NET XML configuration file produces this error:

The value '0 0-45/5 9 * * ?' is invalid according to its datatype

My <trigger> is of the type <cron>. What am I doing wrong?

EDIT: The full XML configuration of the trigger is as follows:

<trigger>
  <cron>
    <name>HealthCheckJobTrigger2</name>
    <group>G</group>
    <description>Run the job from 9:00 to 9:45 every 5 minutes</description>
    <job-name>HealthCheckJob</job-name>
    <job-group>G</job-group>
    <misfire-instruction>SmartPolicy</misfire-instruction>
    <cron-expression>0 0-45/5 9 * * ?</cron-expression>
  </cron>
</trigger>

Solution

  • It does not make sense to specify a set of numbers at intervals. Instead, you should use this:

    0 0,5,10,15,20,25,30,35,40,45 9 * * ?