Python定时任务框架APScheduler 3.0.3 Cron示例
APScheduler是基于Quartz的一个Python定时任务框架,实现了Quartz的所有功能,使用起来十分方便。提供了基于日期、固定时间间隔以及crontab类型的任务,并且可以持久化任务。基于这些功能,我们可以很方便的实现一个python定时任务系统。
安装
安装过程很简单,可以基于pip和源码。
Pip install apscheduler==3.0.3
或者下载源码,运行命令:
Python setup.py install
cron job例子
1: #coding=utf-8
2: from apscheduler.schedulers.blocking import BlockingScheduler
3: from datetime import datetime
4: import time
5: import os
6:
7: def tick():
8: print('Tick! The time is: %s' % datetime.now())
9:
10: if __name__ == '__main__':
11: scheduler = BlockingScheduler()
12: scheduler.add_job(tick,'cron', second='*/3', hour='*')
13: print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
14: try:
15: scheduler.start()
16: except (KeyboardInterrupt, SystemExit):
17: scheduler.shutdown()
18:
19:
20:
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Cron表达
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }式说明
|
Expression |
Field |
Description |
|
* |
any |
Fire on every value |
|
*/a |
any |
Fire every a values, starting from the minimum |
|
a-b |
any |
Fire on any value within the a-b range (a must be smaller than b) |
|
a-b/c |
any |
Fire every c values within the a-b range |
|
xth y |
day |
Fire on the x -th occurrence of weekday y within the month |
|
last x |
day |
Fire on the last occurrence of weekday x within the month |
|
last |
day |
Fire on the last day within the month |
|
x,y,z |
any |
Fire on any matching expression; can combine any number of any of the above expressions |
Python定时任务框架APScheduler 3.0.3 Cron示例的更多相关文章
- Python定时任务框架APScheduler
http://blog.csdn.net/chosen0ne/article/details/7842421 APScheduler是基于Quartz的一个Python定时任务框架,实现了Quartz ...
- [转]Python定时任务框架APScheduler
APScheduler是基于Quartz的 一个Python定时任务框架,实现了Quartz的所有功能,使用起来十分方便.提供了基于日期.固定时间间隔以及crontab类型的任务,并且可以 持久化任务 ...
- Python 定时任务框架 APScheduler 详解
APScheduler 最近想写个任务调度程序,于是研究了下 Python 中的任务调度工具,比较有名的是:Celery,RQ,APScheduler. Celery:非常强大的分布式任务调度框架 R ...
- python 定时任务框架apscheduler
文章目录 安装 基本概念介绍 调度器的工作流程 实例1 -间隔性任务 实例2 - cron 任务 配置调度器 方法一 方法二 方法三: 启动调度器 方法一:使用默认的作业存储器: 方法二:使用数据库作 ...
- 分布式定时任务框架——python定时任务框架APScheduler扩展
http://bbs.7boo.org/forum.php?mod=viewthread&tid=14546 如果将定时任务部署在一台服务器上,那么这个定时任务就是整个系统的单点,这台服务器出 ...
- [Python]定时任务框架 APScheduler
1.使用APScheduler教程 参考博客地址
- Python中定时任务框架APScheduler
前言 大家应该都知道在编程语言中,定时任务是常用的一种调度形式,在Python中也涌现了非常多的调度模块,本文将简要介绍APScheduler的基本使用方法. 一.APScheduler介绍 APSc ...
- Python中定时任务框架APScheduler的快速入门指南
前言 大家应该都知道在编程语言中,定时任务是常用的一种调度形式,在Python中也涌现了非常多的调度模块,本文将简要介绍APScheduler的基本使用方法. 一.APScheduler介绍 APSc ...
- [Dynamic Language] Python定时任务框架
APScheduler是一个Python定时任务框架,使用起来十分方便.提供了基于日期.固定时间间隔以及crontab类型的任务,并且可以持久化任务.并以daemon方式运行应用. 在APSchedu ...
随机推荐
- GJM : 用Unity模仿CSGO里的火焰效果 [转载]
感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...
- [翻译] Autofac 控制范围和生命周期
原文链接:http://docs.autofac.org/en/latest/lifetime/index.html Lifetime 是指服务的实例在程序中存活多久 – 从最初的实例化到清理(dis ...
- 博客迁移到独立域名owenchen.net,此博客不再更新。
博客已迁移到阿里云,自己搭的wordpress,可以有更多的灵活性. 写点代码,放点示例,欢迎访问. owenchen.net
- JS中数组去除重复的方法
function unique(arr) { var result = [], hash = []; for (var i = 0, elem; (elem = arr[i]) != null; i+ ...
- iframe父页面获取子页面的高度
最近做项目中用到了iframe,子页面更改父页面的高度,经过九九八十一难,找到了解决的办法. $(window).load(function() { var h=$(document).height ...
- sql联合查询
联合查询效率较高.以下例子来说明联合查询的好处 t1表结构(用户名,密码) userid int username varchar(20) password ...
- 通过组策略实现Firefox自动以当前域账号登录MOSS站点---(原创)
忘忧草原创,转发请保留本人的大名,谢谢,如果需要文档的请找我索取 前言 通过组策略实现基于AD的windows验证的sharepoint站点在火狐下自动以当前域账号登录. 操作步骤-在服务器添加策略工 ...
- 好推二维码如何通过应用宝微下载支持微信自动打开APP下载?
好推二维码 官网 http://www.hotapp.cn 1. 为什么使用应用宝微下载? APP下载二维码,通过微信扫描下载的时候,微信目前只支持应用宝微下载,才能在微信里直接打开下载,否则就需要在 ...
- GpsLocationProvider中的sendExtraCommand方法
Android系统源码中GpsLocationProvider类中包含sendExtraCommand方法,代码如下 @Override public boolean sendExtraCommand ...
- Android 手机卫士--阶段小结1
本文地址:http://www.cnblogs.com/wuyudong/p/5904528.html,转载请注明源地址. 本文对之前手机卫士开发进行一个小结. 1.SplashActivity 版本 ...