logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.
로그파일이 너무 많아져서 30% 정도의 디스크 용량을 사용하고 있었다.
일정한 주기로 불필요한 많은 양의 로그 파일을 관리에 logrotate command가 있어 활용하였다.
-v Turn on verbose mode. -d Turns on debug mode and implies -v. In debug mode, no changes will be made to the logs or to the logrotate state file. -f, --force Tells logrotate to force the rotation, even if it doesn’t think this is necessary. Sometimes this is useful after adding new entries to logrotate, or if old log files have been removed by hand, as the new files will be created, and logging will con- tinue correctly. -m, --mail <command> Tells logrotate which command to use when mailing logs. This command should accept two arguments: 1) the subject of the mes- sage, and 2) the recipient. The command must then read a message on standard input and mail it to the recipient. The default mail command is /bin/mail -s. -s, --state <statefile> Tells logrotate to use an alternate state file. This is useful if logrotate is being run as a different user for various sets of log files. The default state file is /var/lib/logrotate/sta- tus. --usage Prints a short usage message.
다음과 같은 옵션이 있는데, 훑어보면 되겠다.
/etc/logrotate.d
ex) compress_log
$logpath/*.log {
copytruncate // copy 파일을 생성한 후에 원래의 로그 파일들을 truncate한다
daily
rotate 365
missingok
compress<!-- 오래된 로그파일을 압축 (default : gzip) -->
}
$ logrotate -d /etc/logrotate.d/compress_log
$ logrotate -f /etc/logrotate.d/compress_log (강제로 실행)
참조 URL : http://www.linuxcommand.org/man_pages/logrotate8.html
'server' 카테고리의 다른 글
fluentd와 함께하는 검색 데이터 수집 (0) | 2019.06.26 |
---|---|
Redisson (0) | 2019.06.26 |
ModelMapper (0) | 2019.06.25 |
Lambda@Edge를 활용한 이미지 리사이징 (1) | 2019.03.24 |
WAS 속도 느림 현상 (0) | 2017.02.01 |
댓글