작은숲:위키노트/Logrotate 설정
보이기
(Logrotate 설정에서 넘어옴)
logrotate는 각종 로그 파일의 백업을 자동으로 해주는 도구이다. 이 logrotate를 이용하면 관리자가 매일 특정 로그를 메일로 전송 받고, 압축해서 보관할 수 있다. 아래는 데비안에 설치된 logrotate의 설정 파일인 /etc/logrotate.conf이다.
# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}/var/log/btmp {
missingok
monthly
create 0664 root utmp
rotate 1
}# system-specific logs may be configured here위에 나온 것처럼 설정 파일에 대한 자세한 사항은 man logrotate를 해보면 알 수 있다.
만약 위 설정 외에 추가로 다른 로그 파일에 대해 정리하고 싶다면 /etc/logrotate.d/ 디렉토리 아래에 따로 설정 파일을 만든다. 설정 파일의 디렉토리는 시스템에 따라 차이가 생길 수 있으니 확인해야 한다. 위 logrotate 설정 파일에 보면 include /etc/logrotate.d라는 항목이 있는데, 이것은 /etc/logrotate.d 디렉토리 아래에 있는 파일들을 추가 설정 파일로 읽어 들인다는 뜻이다.
예를 들어 Exim 필터의 로그를 처리하기 위한 설정 파일을 만든다면, /etc/logrotate.d/exim이라는 파일을 만든다. 그런 후 다음의 내용을 추가한다.
# cat /etc/logrotate.d/exim
/var/log/exim/filterlog {
daily
mailfirst root
missingok
create 0640 mail mail
rotate 7
compress
delaycompress
}/var/log/exim/spam.inbox {
daily
missingok
create 0640 mail mail
rotate 7
compress
delaycompress
}이제 Exim 필터의 로그들이 매일 관리자에게 메일로 전송되고, 이후 압축되어 보관된다. 이 압축된 백업 파일은 7일 동안 보관된다.
| 배포판 | |
|---|---|
| 서버 프로그램 | |
| 시스템 도구 | |
| 시스템 보안 | |
| 시스템 설정 | |
| HOWTO 문서 | |
| 사용자 설정 | |
| 활용 | |
| 명령어 | |