리눅스 logrotate.conf
IT위키
더 많은 작업
- 시스템에서 사용하는 로그들이 무한정 쌓이지 않도록 순환 시키는 기능을 하는 설정 파일
- 위치 : /etc/logrotate.conf
- 초기 설정 파일 내용
[root@fran etc]# cat 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
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
| 지시자 | 뜻 |
|---|---|
| daily / weekly / monthly / yearly | 로테이트 주기 |
| rotate N | 남겨 둘 백로그(지난 로그) 파일 개수. rotate 1 이면 1개만 남긴다 |
| create 권한 소유자 그룹 | 로테이트한 뒤 새 로그 파일을 이 허가권·소유자·소유 그룹으로 만든다 |
| size 크기 | 주기와 관계없이 크기만 보고, 이 크기를 넘으면 로테이트한다 |
| minsize 크기 | 주기가 되었더라도 이 크기보다 작으면 로테이트하지 않는다. 주기와 크기 조건을 둘 다 채워야 돈다 |
| maxsize 크기 | 이 크기를 넘으면 주기가 되기 전이라도 로테이트한다 |
| compress / dateext / missingok | 압축, 날짜 붙이기, 파일이 없어도 오류 내지 않기 |
위 /var/log/wtmp 블록은 다음 뜻이다.
- monthly : 한 달마다 로테이트한다
- create 0664 root utmp : 새 파일의 허가권은 0664, 소유자는 root, 소유 그룹은 utmp
- minsize 1M : 한 달이 지나도 파일이 1MB 보다 작으면 로테이트하지 않는다. 한 달이 되기 전에 1MB 를 넘었다고 로테이트하지는 않는다(그것은 maxsize 의 동작이다)
- rotate 1 : 백로그 파일을 1개만 남긴다