python中定时任务schedule

import scheduleimport timedef jop():print("jop ...")print(time.ctime())def exec():# 每5秒做定时任务# schedule.every(

import schedule
import time

def jop():
  print("jop ...")
  print(time.ctime())

def exec():
  # 每5秒做定时任务
  # schedule.every(5).seconds.do(jop)

  # 每天在10:15开始做定时任务
  # schedule.every().day.at('10:15').do(jop)

  # 每分钟做
  # schedule.every(1).minutes.do(jop)

  # 每10分钟做
  # schedule.every(10).minutes.do(jop)

  # 每小时做
  # schedule.every().hour.do(jop)

  # 每周周一的上午10:24开始做
  schedule.every().monday.at('10:24').do(jop)

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

if __name__ == "__main__":
  exec()
  
    

发布者:admin,转转请注明出处:http://www.yc00.com/web/1755004694a5225756.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信