Running APScheduler Job Every nth Day of Month

纵然是瞬间 提交于 2019-12-24 11:40:17

问题


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.

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


回答1:


Using the documentation of the cron trigger:

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')


来源:https://stackoverflow.com/questions/32366288/running-apscheduler-job-every-nth-day-of-month

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!