Python计划:每天安排多次

时间:2018-08-16 17:20:06

标签: python web-scraping scheduler schedule taskscheduler

我试图每天在一天的特定时间(在工作日,周六和周日使用不同的时间)使用schedule来在Python中运行特定功能。但是,在运行代码时,它不起作用(它不会给出错误,但不会运行函数)。是因为调度命令的数量/顺序?

#MONDAY
schedule.every().monday.at('01:28').do(w1)
schedule.every().monday.at('01:30').do(wc1)

schedule.every().monday.at('03:28').do(w2)
schedule.every().monday.at('03:30').do(wc2)

schedule.every().monday.at('05:28').do(w3)
schedule.every().monday.at('05:30').do(wc3)

schedule.every().monday.at('07:28').do(w4)
schedule.every().monday.at('07:30').do(wc4)

schedule.every().monday.at('09:28').do(w5)
schedule.every().monday.at('09:30').do(wc5)

schedule.every().monday.at('11:28').do(w6)
schedule.every().monday.at('11:30').do(wc6)

schedule.every().monday.at('13:28').do(w7)
schedule.every().monday.at('13:30').do(wc7)

schedule.every().monday.at('13:32').do(sendreport)
schedule.every().monday.at('13:34').do(clear)


#TUESDAY
schedule.every().tuesday.at('01:28').do(w1)
schedule.every().tuesday.at('01:30').do(wc1)

schedule.every().tuesday.at('03:28').do(w2)
schedule.every().tuesday.at('03:30').do(wc2)

schedule.every().tuesday.at('05:28').do(w3)
schedule.every().tuesday.at('05:30').do(wc3)

schedule.every().tuesday.at('07:28').do(w4)
schedule.every().tuesday.at('07:30').do(wc4)

schedule.every().tuesday.at('09:28').do(w5)
schedule.every().tuesday.at('09:30').do(wc5)

schedule.every().tuesday.at('11:28').do(w6)
schedule.every().tuesday.at('11:30').do(wc6)

schedule.every().tuesday.at('13:28').do(w7)
schedule.every().tuesday.at('13:30').do(wc7)

schedule.every().tuesday.at('13:32').do(sendreport)
schedule.every().tuesday.at('13:34').do(clear)


#WEDNESDAY
schedule.every().wednesday.at('01:28').do(w1)
schedule.every().wednesday.at('01:30').do(wc1)

schedule.every().wednesday.at('03:28').do(w2)
schedule.every().wednesday.at('03:30').do(wc2)

schedule.every().wednesday.at('05:28').do(w3)
schedule.every().wednesday.at('05:30').do(wc3)

schedule.every().wednesday.at('07:28').do(w4)
schedule.every().wednesday.at('07:30').do(wc4)

schedule.every().wednesday.at('09:28').do(w5)
schedule.every().wednesday.at('09:30').do(wc5)

schedule.every().wednesday.at('11:28').do(w6)
schedule.every().wednesday.at('11:30').do(wc6)

schedule.every().wednesday.at('13:28').do(w7)
schedule.every().wednesday.at('13:30').do(wc7)

schedule.every().wednesday.at('13:32').do(sendreport)
schedule.every().wednesday.at('13:34').do(clear)


#THURSDAY
schedule.every().thursday.at('01:28').do(w1)
schedule.every().thursday.at('01:30').do(wc1)

schedule.every().thursday.at('03:28').do(w2)
schedule.every().thursday.at('03:30').do(wc2)

schedule.every().thursday.at('05:28').do(w3)
schedule.every().thursday.at('05:30').do(wc3)

schedule.every().thursday.at('07:28').do(w4)
schedule.every().thursday.at('07:30').do(wc4)

schedule.every().thursday.at('09:28').do(w5)
schedule.every().thursday.at('09:30').do(wc5)

schedule.every().thursday.at('11:28').do(w6)
schedule.every().thursday.at('11:30').do(wc6)

schedule.every().thursday.at('13:28').do(w7)
schedule.every().thursday.at('13:30').do(wc7)

schedule.every().thursday.at('13:32').do(sendreport)
schedule.every().thursday.at('13:34').do(clear)


#FRIDAY
schedule.every().friday.at('01:28').do(w1)
schedule.every().friday.at('01:30').do(wc1)

schedule.every().friday.at('03:28').do(w2)
schedule.every().friday.at('03:30').do(wc2)

schedule.every().friday.at('05:28').do(w3)
schedule.every().friday.at('05:30').do(wc3)

schedule.every().friday.at('07:28').do(w4)
schedule.every().friday.at('07:30').do(wc4)

schedule.every().friday.at('09:28').do(w5)
schedule.every().friday.at('09:30').do(wc5)

schedule.every().friday.at('11:28').do(w6)
schedule.every().friday.at('11:30').do(wc6)

schedule.every().friday.at('13:28').do(w7)
schedule.every().friday.at('13:30').do(wc7)

schedule.every().friday.at('13:32').do(sendreport)
schedule.every().friday.at('13:34').do(clear)


#SATURDAY
schedule.every().saturday.at('03:28').do(s1)
schedule.every().saturday.at('03:30').do(sc1)

schedule.every().saturday.at('05:28').do(s2)
schedule.every().saturday.at('05:30').do(sc2)

schedule.every().saturday.at('07:28').do(s3)
schedule.every().saturday.at('07:30').do(sc3)

schedule.every().saturday.at('09:28').do(s4)
schedule.every().saturday.at('09:30').do(sc4)

schedule.every().saturday.at('11:28').do(s5)
schedule.every().saturday.at('11:30').do(sc5)

schedule.every().saturday.at('13:28').do(s6)
schedule.every().saturday.at('13:30').do(sc6)

schedule.every().saturday.at('15:28').do(s7)
schedule.every().saturday.at('15:30').do(sc7)

schedule.every().saturday.at('15:32').do(sendreport)
schedule.every().saturday.at('15:34').do(clear)


#SUNDAY
schedule.every().sunday.at('02:58').do(e1)
schedule.every().sunday.at('03:00').do(ec1)

schedule.every().sunday.at('04:58').do(e2)
schedule.every().sunday.at('05:00').do(ec2)

schedule.every().sunday.at('06:58').do(e3)
schedule.every().sunday.at('07:00').do(ec3)

schedule.every().sunday.at('08:58').do(e4)
schedule.every().sunday.at('09:00').do(ec4)

schedule.every().sunday.at('10:58').do(e5)
schedule.every().sunday.at('11:00').do(ec5)

schedule.every().sunday.at('12:58').do(e6)
schedule.every().sunday.at('13:00').do(ec6)

schedule.every().sunday.at('14:58').do(e7)
schedule.every().sunday.at('15:00').do(ec7)

schedule.every().sunday.at('15:02').do(sendreport)
schedule.every().sunday.at('15:04').do(clear)


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

1 个答案:

答案 0 :(得分:2)

应该是评论,但我没有足够的代表:如果您正在使用Linux,则可能要检查cron