推荐学习书目
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
wolong
V2EX  ›  Python

如何知道 python 是如何异常退出的?

  •  
  •   wolong · Apr 22, 2014 · 5951 views
    This topic created in 4430 days ago, the information mentioned may be changed or developed.
    刚学python,做了个自动发送微博的程序,目前设置为早上和晚上各发一条。这个程序在本地的树莓派上能正常长时间运行,但是放到国外vps上运行,正常运行两三天后,就会退出。我想知道退出的原因是什么,要怎样做?vps的系统是debian 7.树莓派是raspbian。
    10 replies    1970-01-01 08:00:00 +08:00
    est
        1
    est  
       Apr 22, 2014
    我来吐槽下:LZ这个问题是典型的——书上没教的都不会系列。。。
    lu18887
        2
    lu18887  
       Apr 22, 2014
    分析日志。
    wolong
        4
    wolong  
    OP
       Apr 22, 2014
    @est 之前在网上搜过,但是不得要领啊。我只有考虑增加几个try except了。

    @lu18887 日志要怎么分析?对于linux和python都是初学。
    Ever
        5
    Ever  
       Apr 22, 2014
    run_your_python_file 2>> error_log_path.log
    lu18887
        6
    lu18887  
       Apr 22, 2014
    @Ever 改进版 run_your_python_file 2&>1 1>> error_log_path.log

    @wolong 在调用你脚本的地方,根据上面我写 的改。然后根据输出的日志进行分析。一般出错都是有一些输出的。上面那个的意思是,把你运行的脚本的 错误输出 append到你的 标准输出,再把标准输出 全部重定向写到日志文件里。
    skydiver
        7
    skydiver  
       Apr 22, 2014
    @lu18887 不应该是 2>&1 么
    lu18887
        8
    lu18887  
       Apr 22, 2014
    @skydiver 嗯,我弄错了、
    arkilis
        9
    arkilis  
       Apr 23, 2014
    try nohup
    wolong
        10
    wolong  
    OP
       Apr 24, 2014
    @lu18887 还是不太理解呢,我是用一段bash脚本加入到启动文件夹里面,开机自动运行python的,这段脚本也是依葫芦画瓢。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1358 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 17:10 · PVG 01:10 · LAX 10:10 · JFK 13:10
    ♥ Do have faith in what you're doing.