每月第n天运行一次APScheduler作业 [英] Running APScheduler Job Every nth Day of Month
本文介绍了每月第n天运行一次APScheduler作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个APScheduler触发器,该触发器将在每月的第n天执行一次作业。例如,我想在每个月的第一个星期二工作。还是在每个月的第一个和第三个星期一。
I'm looking for an APScheduler trigger that will execute a job every nth day of a month. For example, I want to run a job on the first Tuesday of every month. Or on the first and third Monday of every month.
有人能做到这一点吗?您可以使用cron计划程序几乎进行操作,并让您的函数仔细检查它是否在正确的时间运行:> Cron作业可以运行每月的每周的第一个或最后一个选定的日期
Does anyone have a trigger that accomplishes this? You can almost do it with the cron scheduler and having your function double-check that it's running at the right time: Cron job to run every first or last chosen day of week of every month
推荐答案
使用计时触发器:
scheduler.add_job(func, 'cron', day='1st tue')
scheduler.add_job(func, 'cron', day='1st mon,3rd mon')
scheduler.add_job(func, 'cron', day='1st fri,last fri')
这篇关于每月第n天运行一次APScheduler作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文