• 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

  • 相关阅读:
    js-artDialog文档说明
    T-SQL数据库函数
    强大的Jquery对象选择器
    学习正则表达式
    经典正则
    其他常用的正则表达式
    celery的使用
    django中间件
    AJAX
    Django Form表单组件
  • 原文地址:https://www.cnblogs.com/spaceship9/p/3732134.html
Copyright © 2020-2023  润新知