在python中,安排作业仅在特定日期每5分钟运行一次

在python中,安排作业仅在特定日期每5分钟运行一次,python,scheduler,schedule,Python,Scheduler,Schedule,我只想在一周中的某一天每5分钟运行一次cron作业。我使用的是python调度库,我可以单独完成这些工作。但我该怎么用棍棒打他们呢 代码 这会产生一个错误intervaleror:Use mondays而不是monday当我尝试使用mondays时,我会得到一个错误AttributeError:“Job”对象没有属性“mondays”有人能帮我吗。你尝试过使用“time”吗 我认为计划包不支持您想要的不同时间单位的组合。您可以通过以下方式实现自己的目标: import schedule impo

我只想在一周中的某一天每5分钟运行一次cron作业。我使用的是python调度库,我可以单独完成这些工作。但我该怎么用棍棒打他们呢

代码

这会产生一个错误
intervaleror:Use mondays而不是monday
当我尝试使用mondays时,我会得到一个错误
AttributeError:“Job”对象没有属性“mondays”
有人能帮我吗。

你尝试过使用“time”吗


我认为
计划
包不支持您想要的不同时间单位的组合。您可以通过以下方式实现自己的目标:

import schedule
import time
import datetime

def job():
    if datetime.datetime.today().weekday() == 0:
        print("I'm working...")

schedule.every(5).minutes.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

也许不是最优雅的解决方案。

你说的“加入他们”是什么意思?我想每周一,每5分钟做一次这项工作。你在重复问题中已经存在的内容,而不是澄清我问过的奇怪的用词。谢谢你,但是有了这个,我今天不能参加竞选,因为今天是星期一。下一次跑步将在下周一进行
datetime.today().weekday()
做什么?@cvg它只是在检查:“今天是不是星期一”
import time
...

schedule.every().monday.do(job)

while True:
    schedule.run_pending()
    time.sleep(300)
import schedule
import time
import datetime

def job():
    if datetime.datetime.today().weekday() == 0:
        print("I'm working...")

schedule.every(5).minutes.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)