728x90
systemd 로그 메시지 중 사용자 슬라이스(user slice) 로그 메시지를 제거하는 방법
테스트 환경
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
- messages 로그
tail -f /var/log/messages
$ tail -f /var/log/messages
Feb 22 20:51:01 aws-server-01 systemd: Created slice User Slice of webapps.
Feb 22 20:51:01 aws-server-01 systemd: Started Session 489743 of user webapps.
Feb 22 20:51:04 aws-server-01 systemd: Removed slice User Slice of webapps.
Feb 22 20:51:25 aws-server-01 dhclient[2029]: XMT: Solicit on eth0, interval 128450ms.
Feb 22 20:52:01 aws-server-01 systemd: Created slice User Slice of webapps.
Feb 22 20:52:01 aws-server-01 systemd: Started Session 489744 of user webapps.
Feb 22 20:52:02 aws-server-01 systemd: Removed slice User Slice of webapps.
Feb 22 20:53:01 aws-server-01 systemd: Created slice User Slice of webapps.
Feb 22 20:53:01 aws-server-01 systemd: Started Session 489745 of user webapps.
Feb 22 20:53:01 aws-server-01 systemd: Removed slice User Slice of webapps.
Feb 22 20:53:33 aws-server-01 dhclient[2029]: XMT: Solicit on eth0, interval 130050ms.
- ignore-systemd-session-slice.conf 파일 생성
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
- ignore-systemd-session-slice.conf 파일 확인
cat /etc/rsyslog.d/ignore-systemd-session-slice.conf
$ cat /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 서비스 재시작
systemctl restart rsyslog.service
- rsyslog 서비스 상태 확인
systemctl status rsyslog.service
$ systemctl status rsyslog.service
● rsyslog.service - System Logging Service
Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-02-22 21:13:23 KST; 7s ago
Docs: man:rsyslogd(8)
http://www.rsyslog.com/doc/
Main PID: 15896 (rsyslogd)
CGroup: /system.slice/rsyslog.service
└─15896 /usr/sbin/rsyslogd -n
...
Hint: Some lines were ellipsized, use -l to show in full.
728x90
'퍼블릭 클라우드' 카테고리의 다른 글
[aws] amazon-linux-extras 명령어 (0) | 2023.02.27 |
---|---|
[aws] EFK 스택 구성하기(efk stack setup) (0) | 2023.02.24 |
Amazon Linux 2(AMZN2)에서 Redis를 설정하고 보안 설정하는 방법 (0) | 2023.02.21 |
[aws] Amazon Linux 2(AMZN2)에서 Redis를 설치하는 방법 (0) | 2023.02.21 |
[aws] 3fs-fuse를 설치하는 방법 (0) | 2023.02.20 |