Python定时任务:schedule模块
2019-06-19 16:47
148 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_43709411/article/details/92837241
1 import schedule
2 import time
3
4 def test():
5 print(“I’m working…”)
6 def test2():
7 print(“I’m working… in job2”)
8
9 # 每10分钟执行一次job函数
10 schedule.every(10).minutes.do(test)
11 # 每10秒执行一次job函数
12 schedule.every(10).seconds.do(test)
13 # 当every()没参数时默认是1小时/分钟/秒执行一次job函数
14 schedule.every().hour.do(test)
15 schedule.every().day.at(“10:30”).do(test)
16 schedule.every().monday.do(test)
17 # 具体某一天某个时刻执行一次job函数
18 schedule.every().wednesday.at(“13:15”).do(test)
19 # 可以同时定时执行多个任务,但是每个任务是按顺序执行
20 schedule.every(10).seconds.do(job2)
21 # 如果job函数有有参数时,这么写
22 schedule.every(10).seconds.do(job,“参数”)
23 while True:
24 # 启动服务
25 schedule.run_pending()
26 time.sleep(1)
相关文章推荐
- Python3.6 Schedule模块定时任务(实例讲解)
- python的schedule定时任务模块二次封装方法
- nodejs模块 node-schedule使用,定时任务
- nodejs模块 node-schedule使用,定时任务
- python中的轻量级定时任务调度库:schedule
- Python模块学习之Timer定时任务,函数自调实现定时获取博客园博客浏览量
- Python模块学习之Timer定时任务,函数自调实现定时获取博客园博客浏览量
- python实现定时任务那些你不知道的模块
- Python使用crontab模块设置和清除定时任务操作详解
- nodejs模块 node-schedule使用,定时任务
- Python任务调度模块 – APScheduler,Flask-APScheduler实现定时任务
- nodejs模块 node-schedule使用,定时任务
- 基础入门_Python-模块和包.深入Celery之Beat触发定时/周期性任务?
- Python-模块和包.深入Celery之Beat触发定时/周期性任务
- Python定时任务sched模块用法示例
- 定时任务 模块 node-schedule
- 利用python制作在Linux服务器后台定时运行的任务-邮件提醒
- crontab定时任务中不能执行python shell命令
- python设置定时任务(定时执行脚本)
- SpringCloud(第 046 篇)注解式Schedule配置定时任务,不支持任务调度