简体   繁体   English

如何使用apscheduler在特定时间触发工作?

[英]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. 我正在使用python apscheduler模块以不规则的时间间隔触发作业,例如每天的1:30 AM和11:10 PM,但无法找到解决方案。

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. 我不想创建两个工作,一个工作在1:30 AM和11:10 PM。 At least let me know how to do it with crontab so that I will do same with apscheduler. 至少让我知道如何使用crontab进行操作,以便与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. 我浏览了此链接https://apscheduler.readthedocs.io/en/v2.1.2/cronschedule.html#available-fields,但不知道如何做。

APScheduler 3.5.0, due for release shortly, should cover this case: 即将发布的APScheduler 3.5.0应该涵盖以下情况:

from apscheduler.triggers.multi import OrTrigger

trigger = OrTrigger([CronTrigger(hour=1, minute=30), CronTrigger(hour=23, minute=10)]
scheduler.add_job(yourfunc, trigger)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM