nginx log rotation

From WebHostingNeeds.com
Jump to: navigation, search

Edit nginx.conf

vi /etc/nginx/nginx.conf

set pid like as follows

pid       /var/run/nginx.pid;

Create /etc/logrotate.d/nginx

vi /etc/logrotate.d/nginx

Add following content

/var/log/nginx/*log {
    daily
    rotate 10
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
    endscript
}



Nginx