51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos7隐藏messages的slice User信息

在/var/log/messages中发现大量slice User信息,内容如下

Jan 26 00:01:01 nas systemd: Removed slice User Slice of root.
Jan 26 01:01:01 nas systemd: Created slice User Slice of root.
Jan 26 01:01:01 nas systemd: Started Session 6 of user root.
Jan 26 01:01:01 nas systemd: Removed slice User Slice of root.
Jan 26 02:01:01 nas systemd: Created slice User Slice of root.
Jan 26 02:01:01 nas systemd: Started Session 7 of user root.
Jan 26 02:01:01 nas systemd: Removed slice User Slice of root.
Jan 26 03:01:01 nas systemd: Created slice User Slice of root.

造成大量slice User信息原因是和系统systemd服务有关,可通过配置相关规则,来隐藏这些信息。

隐藏该信息方法:
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

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 | 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 |


systemctl restart rsyslog

|---|---------------------------| | 1 | systemctl restart rsyslog |

重启rsyslog后,该信息不再显示

赞(0)
未经允许不得转载:工具盒子 » Centos7隐藏messages的slice User信息