Systemd Python 服务未将所有输出发送到 syslog

fil*_*ter 8 python syslog systemd

我有一个自定义服务,并明确要求将所有 stdout 和 stderr 发送到配置文件中的 syslog,但是只有部分输出出现在 syslog 和日志中(它们是一致的)。

我绝望了,我在服务文件中做了以下事情:

StandardOutput=syslog+console
StandardError=syslog+console
Run Code Online (Sandbox Code Playgroud)

该服务是一个 python 脚本,我使用“打印”语句(Python 2.7)写入标准输出。这些项目似乎丢失了,而其他命令输出正确写入 syslog 和 journald。如果我以交互方式运行脚本,一切都会按预期出现在标准输出中。

我的知识缺乏什么?

fil*_*ter 6

JdeBP 的评论是正确的解决方案:

Systemd Python 服务未将所有输出发送到 syslog

解决方案是向-u解释器添加选项,使标准流发送其输出无缓冲。


归档时间:

查看次数:

6321 次

最近记录:

9 年,3 月 前