faizanjehangir
faizanjehangir

Reputation: 2831

Apscheduler run job every weekday on specific time range

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?

Upvotes: 0

Views: 2312

Answers (2)

RAHUL GUPTA
RAHUL GUPTA

Reputation: 184

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

Upvotes: 1

Alex Grönholm
Alex Grönholm

Reputation: 5901

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

Upvotes: 1

Related Questions