NGinx Logrotate

Written by James McDonald

March 6, 2014

When you start creating virtual hosts under NGinx and give them separate access and error logs don’t forget to update the logrotate configuration otherwise your logs just keep growing.

I have named my logs with .access and .error extensions instead of the default .log option so that has necessitated the following change to the /etc/logrotate.d/nginx file

/var/log/nginx/*log /var/log/nginx/*access /var/log/nginx/*error {
    daily
    rotate 10
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /bin/kill -USR1 $(cat /var/run/nginx.pid 2>/dev/null) 2>/dev/null || :
    endscript
}

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...