消息日志文件每分钟都被淹没

消息日志文件每分钟都被淹没

我的/var/log/messages文件每分钟都会充斥着以下消息:

Dec 15 13:55:01 www systemd: Started Session 31 of user root.
Dec 15 13:55:01 www systemd: Starting Session 31 of user root.
Dec 15 13:55:01 www systemd: Removed slice User Slice of root.
Dec 15 13:55:01 www systemd: Stopping User Slice of root.

这些消息是什么意思?服务器有问题吗?有没有办法阻止他们淹没日志?

答案1

这在基于 systemd 的机器上相对常见。当用户登录、运行 cron 作业、在作业时可能会发生这样的事件...

如果您正在运行rsyslogd,则可以创建一个过滤器来删除这些消息。

例如,在 RedHat(CentOS 等)上,有记录:https://access.redhat.com/solutions/1564823

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

这将阻止本地记录这些事件:

"Starting Session"
"Started Session"
"Created slice"
"Starting user-"
"Starting User Slice of"
"Removed session"
"Removed slice User Slice of"
"Stopping User Slice of"

您可以根据需要调整过滤器。

相关内容