Logrotate
Linux log를 관리해요
References: man7.org, network.com, server-talk.tistory.com
What is Logrotate?
Linux server의 log를 관리하도록 설정하는 기능
보통 기본적으로 설치되어 있다
설치 확인
logrotate
는 log 파일들을 지정한 설정에 맞게 자르고, 압축하고, 삭제하는 것을 대신해준다
How logrotate works
: logrotate는 cron을 통해 동작하는데, 관련된 file들은 아래와 같다
/usr/sbin/logrotate
executable logrotate command
/etc/cron.daily/logrotate
logrotate를 매일 실행하는 shell script
logrotate 작업 내역 log
/etc/logrotate.conf
logrotate 설정 파일
/etc/logrotate.d
logrotate process 설정 파일
/etc/logroate.conf
에 해당 directory를 포함시키도록 설정함
Logrotate 실행 순서
crontab
cron.daily
logrotate
logrotate.conf
logrotate.d
logrotate.conf
아래는 logrotate.conf
의 예시이다
Options
rotate [숫자] : log파일이 5개 이상 되면 삭제
ex) rotate 5
maxage [숫자] : log파일이 30일 이상 되면 삭제
ex) maxage 30
size : 지정된 용량보다 클 경우 rotate 실행
ex) size +100k
create [권한] [유저] [그룹] : rotate 되는 로그파일 권한 지정
ex) create 644 root root
notifempty : 로그 내용이 없으면 rotate 하지 않음
ifempty : 로그 내용이 없어도 rotate 진행
monthly(월 단위) , weekly(주 단위) , daily(일 단위) rotate 진행
compress : rotate 되는 log file gzip 압축
nocompress : rotate 되는 로그파일 gzip 압축 X
missingok : 로그 파일이 발견되지 않은 경우 에러처리 하지 않음
dateext : 백업 파일의 이름에 날짜가 들어가도록 함
Last updated