![logrotate daily+maxsize는 회전하지 않습니다.](https://linux55.com/image/123909/logrotate%20daily%2Bmaxsize%EB%8A%94%20%ED%9A%8C%EC%A0%84%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
CentOS 7.4와 logrotate 3.8.6을 설치했습니다. /etc/logrotate.d/
동일한 시스템에 설치된 Tomcat의 일부 로그(예: catalina.out)를 회전하는 사용자 정의 logrotate 파일이 있습니다 .
/opt/test/apache-tomcat-8.5.15-client/logs/catalina.out {
copytruncate
daily
rotate 30
olddir /opt/test/apache-tomcat-8.5.15-client/logs/backup
compress
missingok
maxsize 50M
dateext
dateformat .%Y-%m-%d
}
매일 또는 크기가 50MB에 도달하면 로그를 교체하고 싶습니다. 이 경우 로그 파일은 압축되어 백업 폴더에 복사되며 삭제되기 전 30일 동안 보관됩니다.
다음 명령을 사용하여 디버그 모드에서 logrotate를 수동으로 실행했는데 오류가 표시되지 않았습니다(그리고 예상되는 압축 로그 파일이 생성되었습니다).
/usr/sbin/logrotate -d /etc/logrotate.d/openncp-tomcat-backoffice 2> /tmp/logrotate.debug
문제가 없으면 /var/lib/logrotate/logrotate.status
파일이 회전된 것처럼 보이지만 그렇지 않습니다.
"/var/log/yum.log" 2017-11-27-19:0:0
"/opt/test/apache-tomcat-8.5.15-server/logs/catalina.out" 2017-12-15-3:41:1
"/var/log/boot.log" 2017-12-15-3:41:1
"/var/log/up2date" 2017-11-27-19:0:0
기본값은 다음과 같습니다 /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
# 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.
나는 또한 기본 하나를 가지고 있습니다 /etc/cron.daily/logrotate
:
#!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
~에 따르면logrotate 맨페이지:
maxsize size
Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval ( daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When maxsize is used, both the size and timestamp of a log file are considered.
지금까지 로그가 50MB에 도달하지 않았으며 며칠 동안 순환이 없는 것을 확인했습니다.
올바르게 구성하는 방법에 대한 지침을 요청합니다.