python schedule processor
run some tasks which could look like CRON within linux/UNIX in python.
Here's a demo which run on ubuntu12.04
sudo pip install apscheduler
then
1) run a task at determained time 指定时间运行某个程序
2) run a task every period 指定周期运行某个程序
For 1)
here is a aps1.py
#coding: utf-8
#特定时间运行
from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.daemonic = False
def job_function(text):
print text
from datetime import datetime
#job = sched.add_date_job(job_function, datetime(2013, 10, 11, 02, 36, 00), ['Hello World'])
job = sched.add_date_job(job_function, datetime(2014, 10, 11, 02, 36, 00), ['Hello World'])
sched.start()
For 2)
here is a aps2.py
#coding: utf-8
# 间隔时间运行的
from apscheduler.scheduler import Scheduler
import time
sched = Scheduler()
sched.daemonic = False
def job_function():
print "wan si ni"
print time.strftime('%Y%m%d%H%M %S')
sched.add_interval_job(job_function, seconds=3)
sched.start()
For more information, you could visit : http://pythonhosted.org//APScheduler/ http://blog.csdn.net/chosen0ne/article/details/7842421
python schedule processor的更多相关文章
- python schedule 任务调度
python schedule可以简单处理一些日常提醒的工作,下面简要说一下用法: import schedule import time def job(): print("I'm wor ...
- Python schedule 库定时任务
Python schedule 库定时任务 schedule的使用 # 用于scrapy定时任务设置 import schedule import time def job(): print(&quo ...
- python——schedule库实现定时任务
今天给脚本加定时任务用到一个schedule库,使用起来很简单方便.https://github.com/dbader/schedulehttps://schedule.readthedocs.io/ ...
- Python框架、库以及软件资源汇总
转自:http://developer.51cto.com/art/201507/483510.htm 很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世 ...
- Machine and Deep Learning with Python
Machine and Deep Learning with Python Education Tutorials and courses Supervised learning superstiti ...
- 针对上一篇文章中的代码,想出的重构方案(python实现)
#!/usr/bin/env python class Processor: def __init__(self, processor): self.processor = processor def ...
- qrcode 4.0.4 : Python Package Index
qrcode 4.0.4 : Python Package Index qrcode 4.0.4 Download qrcode-4.0.4.tar.gz QR Code image generato ...
- 【python】Python框架、库和软件资源大全
很多来自世界各地的程序员不求回报的写代码为别人造轮子.贡献代码.开发框架.开放源代码使得分散在世界各地的程序员们都能够贡献他们的代码与创新. Python就是这样一门受到全世界各地开源社区支持的语言. ...
- Python框架、库和软件资源大全(整理篇)
有少量修改,请访问原始链接.PythonWIn的exe安装包;http://www.lfd.uci.edu/~gohlke/pythonlibs/ 原文链接:codecloud.net/python- ...
随机推荐
- php设计模式(一):简介及创建型模式
我们分三篇文章来总结一下设计模式在PHP中的应用,这是第一篇创建型模式. 一.设计模式简介 首先我们来认识一下什么是设计模式: 设计模式是一套被反复使用.容易被他人理解的.可靠的代码设计经验的总结. ...
- MonkeyRunner于Windows在下面Eclipse开发环境的搭建步骤(并解决在线Jython配置错误的问题)
网上有一shangdong_chu网友写了一篇文章介绍了如何Eclipse构造MonkeyRunner,他做了叙述一个很好的说明.但我对我的环境试验后会见Jython解析错误的问题,和制品缺少Pyde ...
- JAVA进阶-注解
注解元数据分为4部分分别为Target,Documented,Inherited,Retention: Target>指定被注解的注解仅仅能使用在某个类型上;ElementType指定其类型:能 ...
- 推荐几个靠谱的VPN
最近开发scala程序使用sbt构建工程时,下载很慢,有些依赖只能通过VPN才能下载下来.在网上搜索了一大堆提供VPN服务的.有一大部分不提供试用,而且还必须得按年购买,看起来是像骗子. 在这里推荐几 ...
- 提高mysql千万级数据SQL的查询优化30条总结
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...
- DB2数据类型
DB2数据库的内置数据类型主要分成数值型(numeric).字符串型(character string).图形字符串(graphic string).二进制字符串型(binary string)或日期 ...
- oracle 数据库技术支持生命周期表
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl4b3Jh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...
- adb概览及协议参考
原文:https://github.com/android/platform_system_core/blob/master/adb/OVERVIEW.TXT) Implementation note ...
- 第三记“晋IT”分享成长沙龙
2014年8月17日下午4点-7点,第三期"晋IT"分享成长沙龙在太原大自然蒙特梭利幼儿园多功能厅成功举办. 8月17日下午两点.小编领先来到场地,提前探訪一下准备情况. &quo ...
- ActiveReports 9实战教程(1): 手把手搭建环境Visual Studio 2013 社区版
原文:ActiveReports 9实战教程(1): 手把手搭建环境Visual Studio 2013 社区版 ActiveReports 9刚刚发布3天,微软就发布了 Visual Studio ...