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?

Asked By: faizanjehangir

||

Answers:

You can just add hour='9-17' to accomplish that.

Answered By: Alex Grönholm

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
Answered By: RAHUL GUPTA
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.