Apscheduler run job every weekday on specific time range
Question:
I have a current apscheduler
that runs the job mon-fri
and an interval of ~4 mins
all day long. Is it possible to run the job for a specific time range? Lets say from 9:00 am to 5:00 pm
in this case?
My expression looks like this:
scheduler.add_job(feed_data, 'cron', day_of_week='mon-fri', minute='*/3', jitter=30)
Is it possible to add start/end datetime
to this expression?
Answers:
You can just add hour='9-17'
to accomplish that.
Here is simple answer:-
scheduler.add_job(
func=lambda: monday_break_scheduler(),
trigger=CronTrigger(day_of_week='mon', hour=17, minute=40)
)
also import this
from apscheduler.triggers.cron import CronTrigger
I have a current apscheduler
that runs the job mon-fri
and an interval of ~4 mins
all day long. Is it possible to run the job for a specific time range? Lets say from 9:00 am to 5:00 pm
in this case?
My expression looks like this:
scheduler.add_job(feed_data, 'cron', day_of_week='mon-fri', minute='*/3', jitter=30)
Is it possible to add start/end datetime
to this expression?
You can just add hour='9-17'
to accomplish that.
Here is simple answer:-
scheduler.add_job(
func=lambda: monday_break_scheduler(),
trigger=CronTrigger(day_of_week='mon', hour=17, minute=40)
)
also import this
from apscheduler.triggers.cron import CronTrigger