Rotate Nginx vHosts Log Files with Logrotate

Posted on October 5, 2016 at 11:21 pm

Edit /etc/logrotate.d/nginx and add:

/var/www/vhosts/*/logs/*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 nginx adm
        sharedscripts
        postrotate
                [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
        endscript
}

Log files will be rotate 52 times (days) before being removed

Updated on January 18, 2017 at 7:55 pm

Receive updates via email

Other Posts

Updated Posts