Python的时间调度Apscheduler
2018-01-19 10:42
288 查看
下载:
导入:
1.周期任务的简单应用(interval)
2.定时任务的简单应用(date)
3.定时任务的简单应用(cron)
#下载命令 pip install apscheduler
导入:
from apscheduler.schedulers.blocking import BlockingScheduler
1.周期任务的简单应用(interval)
# -*- coding: utf-8 -*- from apscheduler.schedulers.blocking import BlockingScheduler #定义周期调度的方法 def aps(): print '这里是调度方法' #主函数 if __name__ == '__main__': sched = BlockingScheduler() #每10秒执行一次aps sched.add_job(aps, 'interval',seconds='10') ''' 常用的参数 seconds 每隔多少秒执行一次 minutes 每隔多少分钟执行一次 hours 每隔多少小时执行一次 days 每隔多少天执行一次 weeks 每隔多少周执行一次 '''
2.定时任务的简单应用(date)
# -*- coding: utf-8 -*- from apscheduler.schedulers.blocking import BlockingScheduler #定义定时调度的方法 def aps(): print '这里是定时方法' #主函数 if __name__ == '__main__': sched = BlockingScheduler() #在相应的时间执行一次 sched.add_job(aps, 'date',run_date='2018-01-01 11:11:11')
3.定时任务的简单应用(cron)
# -*- coding: utf-8 -*- from apscheduler.schedulers.blocking import BlockingScheduler #定义定时调度的方法 def aps(): print '这里是定时方法' #主函数 if __name__ == '__main__': sched = BlockingScheduler() #在每年的1-12月份9日15时30分0秒执行一次(每个月的9日15时30分0秒执行一次) sched.add_job(aps, 'cron',month='1-12', day='09', hour='15',minute='30',second='0'))
参考:
https://www.cnblogs.com/luxiaojun/p/6567132.html相关文章推荐
- python调度框架APScheduler使用详解
- python调度框架APScheduler使用详解
- Python的任务调度模块APScheduler学习3(作业运行控制-trigger)
- python编写网页爬虫脚本并实现APScheduler调度
- Python任务调度模块 – APScheduler
- 详解python调度框架APScheduler使用
- python 调度框架APScheduler使用详解
- Python任务调度模块 – APScheduler
- Python定时任务调度——APScheduler
- Python任务调度模块 – APScheduler
- Python任务调度模块 – APScheduler,Flask-APScheduler实现定时任务
- Python任务调度模块 – APScheduler
- Python的任务调度模块APScheduler学习1(基本认识)
- Python任务调度模块 – APScheduler
- Python任务调度模块 – APScheduler
- Python 任务调度-APScheduler
- Python的任务调度模块APScheduler学习2(作业操作)
- 【python】Python任务调度模块 – APScheduler
- Python任务调度模块 – APScheduler
- python调度框架APScheduler使用详解