CentOS7の場合
# vi /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
↓変更
#/var/log/httpd/*log {
# missingok
# notifempty
# sharedscripts
# delaycompress
# postrotate
# /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
# endscript
#}
/var/log/httpd/*log {
daily
missingok
notifempty
sharedscripts
rotate 12
weekly
delaycompress
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
CentOS6の場合
# vi /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
↓変更
/var/log/httpd/*log {
daily
missingok
notifempty
sharedscripts
rotate 12
weekly
compress
postrotate
/bin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
ドライランでテスト
# logrotate -dv /etc/logrotate.d/httpd
running postrotate script
running script with arg /var/log/httpd/*log : "
/sbin/service httpd reload > /dev/null 2>/dev/null || true
"
removing old log /var/log/httpd/access_log.8
error: error opening /var/log/httpd/access_log.8: No such file or directory
# mv /var/lib/logrotate.status /var/lib/logrotate.status_bak-20180104 # touch /var/lib/logrotate.status
強制ログロテート
# logrotate -f /etc/logrotate.conf
# httpd -t # systemctl reload httpd
Nginxの場合の例
# vi /etc/logrotate.d/nginx
/var/log/nginx/*log {
missingok
minsize 100M
notifempty
sharedscripts
rotate 12
weekly
compress
postrotate
kill -USR1 `cat /var/run/nginx.pid`
endscript
}

