shell下python脚本的输出转向

一个用python写的脚本,在本地测试的时候用python的print输出了一些状态信息,用于观测程序运行的状况。脚本自身比较耗时(中间故意设置了延时)。
在部署到服务器上后,需要后台运行,因此就想当然的转向输出到一个文本log中:
python script.py > output.log &
结果发现log文件一直是空白(程序在持续运行中),但正常应该是有文本记录的。结果网上搜索才发现,python脚本默认是在脚本整个执行完成后才输出的。(参考:https://unix.stackexchange.com/questions/182537/write-python-stdout-to-file-immediately/182542#182542
当然,知道问题后解决方案也很简单:
python -u script.py > output.log &


已发布

分类

来自

标签:

评论

《 “shell下python脚本的输出转向” 》 有 13 条评论

  1. androxal ONLINE FEDEX COD FREE CONSULT

    buy androxal generic form

  2. buy cheap enclomiphene cheap real

    buy enclomiphene overnight free delivery

  3. rifaximin to purchase uk

    how to order rifaximin generic london

  4. buy xifaxan without a prescription overnight shipping

    buy xifaxan buy in the uk

  5. order avodart generic pricing

    how do i get avodart without a prescription

  6. buy staxyn usa discount

    cheapest staxyn online without prescription

  7. kamagra commande expédition le lendemain

    existe-t-il un médicament générique pour kamagra

  8. cheapest buy dutasteride without a rx

    cheap dutasteride generic is it legal

  9. cheapest buy flexeril cyclobenzaprine lowest price

    online order flexeril cyclobenzaprine generic switzerland

  10. can i get fildena at at wal-mart store without a prescrition

    purchase fildena generic information

  11. how to order gabapentin generic overnight shipping

    how to buy gabapentin purchase tablets

  12. order itraconazole cheap now

    ordering itraconazole uk suppliers

  13. online nás kamagra

    mohli bych získat obecný kamagra online levně

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注