Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

systemd メッセージ (Created slice, Starting Session) でログがいっぱいになる

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 7、8、9

Issue

  • 新しくインストールしたシステムで、/var/log/messages とジャーナルに常に次のメッセージが表示されます。

    Jul 24 08:50:01 example.com systemd: Created slice user-0.slice.
    Jul 24 08:50:01 example.com systemd: Starting Session 150 of user root.
    Jul 24 08:50:01 example.com systemd: Started Session 150 of user root.
    Jul 24 09:00:01 example.com systemd: Created slice user-0.slice.
    Jul 24 09:00:02 example.com systemd: Starting Session 151 of user root.
    Jul 24 09:00:02 example.com systemd: Started Session 151 of user root.
    

Resolution

  • /var/log/messages およびジャーナルでこれらのログエントリーを抑制するには、次のオプションがあります。

    • ユーザーの残留を有効にして、ユーザーにアクティブなセッションがなくても systemd --user インスタンスが引き続き実行されるようにします。
    # loginctl enable-linger testuser
    
    • ユーザーの systemd ユーザーマネージャーのログ記録を制限します。
    # mkdir /etc/systemd/system/user@1000.service.d
    # cat > /etc/systemd/system/user@1000.service.d/logging.conf <<EOF
    [Service]
    LogLevelMax=notice
    EOF
    
    • systemd ユーザーマネージャーのロギングをグローバルに制限します。
    # sed -i -e 's/#LogLevel=info/LogLevel=notice/' /etc/systemd/user.conf
    
    • RHEL 7 で、rsyslog を使用して破棄フィルターを作成します。たとえば、以下のコマンドを実行します。
    echo 'if $programname == "systemd" and ($msg contains "Starting Session" or $msg contains "Started Session" or $msg contains "Created slice" or $msg contains "Starting user-" or $msg contains "Starting User Slice of" or $msg contains "Removed session" or $msg contains "Removed slice User Slice of" or $msg contains "Stopping User Slice of") then stop' >/etc/rsyslog.d/ignore-systemd-session-slice.conf
    

    続いて、rsyslog サービスを再起動します。

    systemctl restart rsyslog
    

    注記: 上記のルールがローカル syslog ロギング (/var/log/messages) でのみ機能し、リモート syslog サーバーでは機能しない場合は、syslog イベントが syslog サーバーに送信された後にこのルールが読み取られることがわかります。したがって、これを回避するには、リモート syslog 送信設定の行の上にある rsyslog.conf に直接、ルールを追加します。(*.* @@sys-log server)

Root Cause

  • これらのメッセージに問題はなく、想定内のものと言えます。これらは、ユーザーがログインしたとき、またはユーザーに対して cron ジョブが実行されたときに表示されます。

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments