Cron expression for every five minutes in the next n hours?

Alex Pi picture Alex Pi · Sep 25, 2013 · Viewed 52.5k times · Source

I know every five minutes is:

0 0/5 * * * *

But how do I limit the number hours for this to happen?

Example: Every five minutes for the next 10 hours.

Answer

Khurram picture Khurram · Dec 16, 2013

Use the range operator to specify the hours. For example, for running the job every five minutes for 10 hours starting at 2 am:

0 0/5 2-12 * * *

Here is an excellent tutorial on Cron expression and operators: http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html

Edit: 10/3/2016: Updated the link.