Reputation: 1121
I'm trying to write a Spring cron expression to have my code execute after a fixed interval of time and between a given interval of time. I would like the code to be executed after every 20 minutes and between 6.00am to 6.00pm that is during day time.
Following is the expression for running the code every 20 min but i am not getting how to restrict it to run between a given interval of time (Can i restrict the schedular in cron expression or i will have to implement the logic in the code that is java class).
<task:scheduled-tasks>
<task:scheduled ref="commonSchedulerForSms" method="sendCommonSmsReport"
cron="0 0/20 * * * ?" />
</task:scheduled-tasks>
I am working on Spring VERSION 3.0, Servlet version 2.5 and Java version 1.6.
Thanks in Advance.
Upvotes: 0
Views: 621
Reputation: 8074
Try this expression:
0 0/20 6-17 * * ?
Fires every 20 minutes from 6 am to 5:40 pm (06:00 to 17:40)
Upvotes: 2