CentOS7

ログの出力を抑制する

新規にインストールしたシステムで、常に /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 9:00:01 example.com systemd:Created slice user-0.slice.
Jul 24 9:00:02 example.com systemd:Starting Session 151 of user root.
Jul 24 9:00:02 example.com systemd:Started Session 151 of user root.

以下のようなファイルを作成する。

[root@localhost ~]# vi /etc/rsyslog.d/ignore-systemd-session-slice.conf
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

rsyslogを再起動して反映し、/var/log/messages に出力されなくなった事を確認する。

[root@localhost ~]# systemctl restart rsyslog

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-09-06 (木) 23:42:28