推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
seizetheday
V2EX  ›  Python

求推荐 python 的任务管理的方法

  •  
  •   seizetheday · Dec 7, 2016 · 5424 views
    This topic created in 3468 days ago, the information mentioned may be changed or developed.
    比如,有 3 个 py 文件: a.py, b.py, c.py

    希望:
    1. 17 : 00 执行 a.py
    2. 每隔 5 分钟执行 b.py
    3. 每隔 1 天执行 c.py

    通过什么包来管理这些任务比较好?

    环境: python 2.7, linux/windows
    24 replies    2017-06-07 22:55:03 +08:00
    DozySun
        1
    DozySun  
       Dec 7, 2016
    apscheduler
    tonghuashuai
        2
    tonghuashuai  
       Dec 7, 2016   ❤️ 1
    这样的情况一般用 crontab 最简单把,其他的包什么的估计还得写代码去调度。
    sinux
        3
    sinux  
       Dec 7, 2016
    native cron
    SlipStupig
        4
    SlipStupig  
       Dec 7, 2016
    @tonghuashuai 我也是用 crontab ,但是不知道为什么任务根本没执行
    sevncz
        5
    sevncz  
       Dec 7, 2016
    crontab +1
    sunwei0325
        6
    sunwei0325  
       Dec 7, 2016
    airflow
    tonghuashuai
        7
    tonghuashuai  
       Dec 7, 2016
    @SlipStupig print 下 log 看看
    smartdie
        8
    smartdie  
       Dec 7, 2016
    一般用 crontab ,
    如果你的项目里用 celery 了,可以考虑 celery beat
    glasslion
        9
    glasslion  
       Dec 7, 2016
    这种简单 情况, crontab 最合适,
    windfarer
        10
    windfarer  
       Dec 7, 2016
    crontab 用用就行了
    cdwyd
        11
    cdwyd  
       Dec 7, 2016 via Android
    @SlipStupig
    我也遇到了手动运行正常 crontab 不执行的问题,后面发现是路径问题,加一个 os.chdir 到工作目录就可以了
    qweweretrt515
        12
    qweweretrt515  
       Dec 7, 2016
    celery
    brucedone
        13
    brucedone  
       Dec 7, 2016
    clino
        14
    clino  
       Dec 7, 2016 via Android
    buildbot
    lunaticus7
        15
    lunaticus7  
       Dec 7, 2016
    celery
    FiveDDD
        16
    FiveDDD  
       Dec 7, 2016
    不想添加依赖,就 crontab ;另外项目的话,可以试试 celery , apscheduler 。
    Contextualist
        17
    Contextualist  
       Dec 7, 2016 via iPad
    个人比较喜欢 https://github.com/dbader/schedule ,适合简单的任务,比 apscheduler 更轻
    SlipStupig
        18
    SlipStupig  
       Dec 7, 2016
    @cdwyd 手动我也不执行
    这个是我的配置文件

    30 23 * * * /home/ubuntu/drogen/starup.sh > /dev/null 2>&1
    10 1 * * 6,0 python ~/jdspier/spidermain.py > /dev/null 2>&1
    */1 * * * * /bin/bash /home/cron.sh > /dev/null 2>&1Ø
    clino
        19
    clino  
       Dec 7, 2016 via Android
    buildbot 这种自动构建软件有个好处是能在 web 上看所有 stdio 输出
    Lycnir
        20
    Lycnir  
       Dec 7, 2016
    crontab 尽量用全路径
    Chyroc
        21
    Chyroc  
       Dec 8, 2016
    luigi?
    zhuf
        22
    zhuf  
       Dec 8, 2016
    apscheduler 比较方便
    glogo
        23
    glogo  
       Dec 8, 2016
    celery beat 可以,不过比较重型了
    heraldboy
        24
    heraldboy  
       Jun 7, 2017
    linux 好处理,关键是 windows 下大家有什么好建议
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2518 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
    ♥ Do have faith in what you're doing.