在运行级别运行的另一个脚本中运行Python Deamon脚本

时间:2016-01-19 09:34:42

标签: python operating-system openwrt

我在运行守护程序时将stdout指定为def __init__(self, basemac, timeout, command, address, port): self.stdin_path = '/dev/null' self.stdout_path = '/tmp/deamon.log' self.stderr_path = '/tmp/daemon.log' self.pidfile_path = '/tmp/apstats_client.pid' self.pidfile_timeout = 5

./apstats.py

我正在尝试运行此脚本,因为tail -f /tmp/daemon.log在运行级别为99的另一个运行级脚本中启动。

当我执行{{1}}(在我们测试它的硬件上)时,我看到stdout会在一段时间之后被刷新。有人知道这背后的原因吗?

1 个答案:

答案 0 :(得分:0)

Python输出被缓冲。在控制台上它与终端同步。对于写日志,我建议使用logging模块。

您可以使用python -u运行python。然后stdout会刷新每次写入。

相关问题