zoukankan      html  css  js  c++  java
  • python apscheduler的使用

    from apscheduler.schedulers.blocking import BlockingScheduler
    from datetime import datetime
    def my_job(x=None): print 'hello world'   print x sched = BlockingScheduler() sched.add_job(my_job, 'interval', seconds=5) #每5秒执行一次 sched.start()
    ############
    
    







    apscheduler 官网http://pypi.python.org/pypi/APScheduler/2.0.3

    from apscheduler.schedulers.blocking import BlockingScheduler
    def my_job(x=None):
    print x

    sched = BlockingScheduler()
    sched.add_job(my_job, 'interval', seconds=2, start_date='2017-02-22 17:46:59',args=['123'])#
    start_date开始没2秒执行一次

    interval 间隔调度

    它的参数如下:

    weeks(int) – number of weeks to wait

    days(int) – number of days to wait

    hours(int) – number of hours to wait

    minutes(int) – number of minutes to wait

    seconds(int) – number of seconds to wait

    start_date(datetime|str) – starting point for the interval calculation

    end_date(datetime|str) – latest possible date/time to trigger on

    更多:http://www.tuicool.com/articles/FbeIRzI

    http://www.cnblogs.com/timliucn/p/5894361.html

    $ pip install schedule
    import schedule
    import time
    
    def job():
        print("I'm working...")
    
    schedule.every(10).minutes.do(job)
    schedule.every().hour.do(job)
    schedule.every().day.at("10:30").do(job)
    schedule.every().monday.do(job)
    schedule.every().wednesday.at("13:15").do(job)
    # schedule.every(1).seconds.do(job)
    while True: schedule.run_pending() time.sleep(1)

    https://pypi.python.org/pypi/schedule/官网地址
  • 相关阅读:
    a.default.ERROR.httpAjax is not a function
    Java heap space
    jmeter
    sql注入
    数据库查前三名
    maven
    国际化变现应用分析
    百度应用部署秘籍
    如何建立起一套有效的APP监控体系
    第三方舆情收集与质量闭环建设
  • 原文地址:https://www.cnblogs.com/wanghaonull/p/6430340.html
Copyright © 2011-2022 走看看