nginx logrotate script

July 13, 2012

nginx logrotate script

Create a new file at /etc/logrotate.d/nginx with contents:


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

Run Logrotate

# /etc/cron.daily/logrotate