LinuxにNginxログローテートlogrotateの設定方法
#cd /etc/logrotate.d
#vi /etc/logrotate.d/nginx
編集内容
/usr/local/nginx/logs/*.log /usr/local/nginx/logs/nginx_logs/*.log{
missingok
dateext
notifempty
daily
rotate 7
sharedscripts
postrotate
if [ -f /usr/local/nginx/logs/nginx.pid ]; then
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
fi
endscript
}
:wq!
#chmod +x /etc/logrotate.d/nginx
shellを実行
#/usr/sbin/logrotate -vf /etc/logrotate.d/nginx
crontab -e
0 0 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/nginx