springcronquartz-schedulercronexpression

Run a cron job every 5 minute only on specific hours?


I want to run some cronjob between monday-friday at 23.50 and 23.55. I tried some expressions but there is something wrong with my expression.

0 50/5 23-00 ? *  MON-FRI

When I calculate next days with cronmaker it shows;

1.  Tuesday, March 15, 2016 11:50 PM
2.  Tuesday, March 15, 2016 11:55 PM
3.  Wednesday, March 16, 2016 12:50 AM
4.  Wednesday, March 16, 2016 12:55 AM
5.  Wednesday, March 16, 2016 11:50 PM

Why it shows AM? I only specified 23-00 hours?


Solution

  • It should be 0 50/5 23 ? * MON-FRI

    '-' specifies range. So, 0 50/5 23-00 ? * MON-FRI means 11pm to 12am