美文网首页
python nohup linux 后台运行输出

python nohup linux 后台运行输出

作者: Python研究者 | 来源:发表于2020-08-21 17:16 被阅读0次

    [python nohup linux 后台运行输出]

    遇到问题

    nohup python flush.py &
    

    这样运行,生成了nohup.out文件,但是内容始终是空的,试了半天也不行。浪费了不少时间。
    原因

    python的输出又缓冲,导致out.log并不能够马上看到输出。
    
    -u 参数,使得python不启用缓冲。
    

    解决

    nohup python -u flush.py > flush.log 2>&1 &

    关注公众号:Python爬虫数据分析挖掘,学习更多python知识

    image

    相关文章

      网友评论

          本文标题:python nohup linux 后台运行输出

          本文链接:https://www.haomeiwen.com/subject/mkqpjktx.html