4

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.

Charith Prabhagya
  • 189
  • 1
  • 3
  • 11
user2753523
  • 473
  • 2
  • 8
  • 23
  • Why don't you want to create two jobs? What's wrong with it? – Sraw Dec 12 '17 at 03:13
  • maintainance will be problem. For example if the user want to stop then he has to stop two jobs. Consider if there are 10 irregular intervals then will be a big problem and also tracking the status of each job also a problem. – user2753523 Dec 12 '17 at 03:15
  • link in your question seems dead – alper Jun 06 '22 at 22:42

1 Answers1

8

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)
Alex Grönholm
  • 5,563
  • 29
  • 32