【问题标题】:Systemd dropping random pieces of stdoutSystemd 丢弃随机的标准输出
【发布时间】:2017-10-05 23:50:51
【问题描述】:

Journalctl 似乎跳过了相应服务正在输出的进程的一些输出。这是怎么回事?

这是一个小例子:我有一个名为tester.py的脚本

import time
count = 0
while True:
    time.sleep(.001)
    count += 1
    print count

我有以下名为tester.service的服务

[Unit]
Description=lots of output
After=network.target

[Service]
User=django
Group=django
WorkingDirectory=/home/django
ExecStart=/usr/bin/python -u tester.py
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

在运行sudo systemctl start tester 并等待几秒钟后,我再运行sudo journalctl -u tester

我注意到输出跳过了大块的数字。例如,下面是一段摘录:

Oct 05 23:44:00 staging python[23185]: 999
Oct 05 23:44:00 staging python[23185]: 1000
Oct 05 23:44:00 staging python[23185]: 1001
Oct 05 23:44:29 staging python[23185]: 26829
Oct 05 23:44:29 staging python[23185]: 26830
Oct 05 23:44:29 staging python[23185]: 26831
Oct 05 23:44:29 staging python[23185]: 26832
Oct 05 23:44:29 staging python[23185]: 26833

【问题讨论】:

  • 包括你正在使用的systemd的版本。
  • 如果您查看完整的journalctl 输出,是否也存在差距?
  • 天哪,这是限速的!不带任何参数的 journalctl 显示 Suppressed xxx messages from /system.slice/tester.service.. 默认为每 30 秒 1000 条消息。谢谢@MarkStosberg

标签: python ubuntu unix logging systemd


【解决方案1】:

Systemd 正在限制您的输出!默认为 30 秒输出 1000 行。您可以在/etc/systemd/journald.conf 中更改此设置

您可以通过单独运行journalctl 来验证这是不是问题所在。您将看到Suppressed xxx messages from /system.slice/tester.service

形式的消息

【讨论】:

    猜你喜欢
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    相关资源
    最近更新 更多