Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use apscheduler to trigger job at specific times?

I am using python apscheduler module to trigger job at irregular intervals for example at 1:30 AM and 11:10 PM on every day, but not able to find a solution to this.

Could you please help me how to do it. I don't want to create two jobs, one for 1:30 AM and 11:10 PM. At least let me know how to do it with crontab so that I will do same with apscheduler. Thanks.

I went through this link https://apscheduler.readthedocs.io/en/v2.1.2/cronschedule.html#available-fields but not getting an idea of how to do it.

like image 325
user2753523 Avatar asked Oct 27 '25 03:10

user2753523


1 Answers

APScheduler 3.5.0, due for release shortly, should cover this case:

from apscheduler.triggers.multi import OrTrigger

trigger = OrTrigger([CronTrigger(hour=1, minute=30), CronTrigger(hour=23, minute=10)]
scheduler.add_job(yourfunc, trigger)
like image 170
Alex Grönholm Avatar answered Oct 28 '25 17:10

Alex Grönholm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!