Seems nginx log rotate doesn't work


#1

I’ve checked my nginx access log files and some of them are more than 1GB in size and contains almost one year old entries (29/Mar/2015:08:43:42 this is the first entry)

Here is the content of the logrotate config:

/var/log/nginx/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 0640 www-data adm
        sharedscripts
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi \
        endscript
        postrotate
                [ -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
        endscript
}

#2

This cron job handles the rotation :

invoke-rc.d nginx rotate >/dev/null 2>&1

As per your issue, what you can do is:

  1. Make configuration files backups, remove nginx, use --purge in case of apt-get then use

apt-get autoremove

  1. Reboot the system once, do apt-get update, then check if your favorite repo is added or not , like rtcamp’s ppa or mainline ppa, if not add the repo. They are in /etc/apt/
  2. After checking/adding repo’s do

apt-get update && apt-get upgrade -y && aptitutude upgrade -y

  1. Reinstall nginx and restore your configurations back, if the problem still persists then the issue must lie with other service in your system

#3