CRON expression for firing a scheduled job between two hours including last one

cron

I have a job scheduled via Quartz and a CRON Expression. The goal of my CRON expression is to run every 10 minutes every day between Monday and Friday between 08:00 AM and 20:00 PM and looks like this:

0 0/10 8-19 ? * MON-FRI

My execution log looks like this:

2010-02-24 19:10:00,140 INFO  - Start
2010-02-24 19:20:00,015 INFO  - Start
2010-02-24 19:30:00,015 INFO  - Start
2010-02-24 19:40:00,015 INFO  - Start
2010-02-24 19:50:00,000 INFO  - Start //Execution expected at 20:00 PM
2010-02-25 08:00:00,000 INFO  - Start
2010-02-25 08:10:00,000 INFO  - Start
2010-02-25 08:20:00,000 INFO  - Start
2010-02-25 08:30:00,000 INFO  - Start
2010-02-25 08:40:00,000 INFO  - Start
2010-02-25 08:50:00,000 INFO  - Start
2010-02-25 09:00:00,000 INFO  - Start
2010-02-25 09:10:00,000 INFO  - Start

I would like that my CRON expression will fire my job at 20:00 PM. Question: Can this be accomplished using one CRON expression? which one?

Best Answer

Why should it run at 20:00? You specify that the hour should be 8-19, so 20:00 doesn't match that. I am not sure if there can be a single line cron expression to accomplish your needs, but you could easily add a line

0 20 * * * ...

in addition to the existing one, that should do the trick.

Related Topic