logrotate란 linux 시스템에서 로그 파일을 자동으로 관리하기 위한 유틸리티이다.
logrotate를 수정하기 위해서는 /etc/logrotate.conf를 보면 된다.
# see "man logrotate" for details
# global options do not affect preceding include directives
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# system-specific logs may also be configured here.
~
위 설정이 logrotate.conf의 설정이다.
이 파일을 보면 결국 logratete.d의 폴더를 포함하고 있어 실질적인 수정이 필요하다면 /etc/logrotate.d/ 하위에서 해결하면 된다.
logrotate.d 폴더를 보면 하위에 각각
btmp, chrony, dnf, psacct, rsyslog, sssd, wtmp가 있다.
각각 로그인 시도, 시스템 시간 동기화, 패키지, 사용자 명령 실행 내역, 전반적 시스템 로그, 사용자 인증, 로그인 세션 지속 시간에 관한 로그이다.
/var/log/messages {
monthly # 로그를 월간 단위로 회전
rotate 12 # 12번 회전하여 약 1년치 로그 보관
missingok # 파일이 없더라도 에러를 발생시키지 않음
compress # 이전 로그 파일을 압축하여 공간 절약
delaycompress # 회전 직후의 로그는 압축하지 않음 (다음 회전 시 압축)
notifempty # 로그 파일이 비어있으면 회전하지 않음
create 0640 root adm # 새 로그 파일을 생성하고 권한 설정
sharedscripts
postrotate
/usr/bin/systemctl kill -s HUP rsyslog.service >/dev/null 2>&1 || true
endscript
}
각각의 파일은 이런식으로 수정하면 된다.
월간 단위로 회전시킬거면 monthly, 주간으로 할거면 weekly, 일간으로 할거면 daily
rotate는 회전시기를 정하는 것이다.
제대로 적용됐는지 확인하려면 logrotate -f 명령어를 사용하면 된다.
'[Linux]' 카테고리의 다른 글
[Linux] grub 부팅이란 무엇이가 (0) | 2024.11.18 |
---|---|
/etc/systemd 와 /usr/lib/systemd 의 차이점 (1) | 2024.11.01 |
리눅스 메모리 사용량 확인 명령어 (0) | 2024.10.28 |
[Linux] su 와 su - 의 차이점 (0) | 2024.10.28 |
인프라 무중단 배포 방식 (0) | 2024.10.24 |