I want to schedule a job mon-fri, between two given times, say 10:20 to 18:35, for every 5 minute.
So it will run: 10:25, 10:30, 10:35, ..., 18:30, 18:35. every weekday.
I tried combining CronTrigger with IntervalTrigger but wasn't able to make it. Can anyone help?
I was able to do this using combining multiple CronTrigger
s using an OrTrigger
.
OrTrigger([
CronTrigger(day_of_week='mon-fri', hour='10', minute='25-59/5'),
CronTrigger(day_of_week='mon-fri', hour='11-17', minute='*/5'),
CronTrigger(day_of_week='mon-fri', hour='18', minute='0-35/5')
])
The first CronTrigger
is for the starting hour (i.e. 10), adjusted the minutes to run only from the 25th minute, every 5 minutes. The middle trigger runs every 5 minutes till the 17th hour. The last one is for the last hour, till the 35th minute.
This solution can be generalized to any start time, end time, and interval.