2

I am trying to rotate nginx log using Logrotate.It's appending log to same file (error.log and access.log) but not rotating on daily basis. Below are the configuration file for the same. Please let me know if i am missing anything.

/var/log/nginx/*.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
}

$ more /etc/cron.daily/logrotate

#!/bin/sh

/usr/sbin/logrotate  /etc/logrotate.conf >/dev/null 2>&1
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

SELinux status

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
UnixAdmin
  • 31
  • 1
  • 2

2 Answers2

1

Are you sure you are not missing "`" 's surrounding the cat command ? According to: http://drumcoder.co.uk/blog/2012/feb/03/nginx-and-logrotate/

Also could you check out /var/log/audit/audit.log for something about "nginx", Auditing System auditd is started by default. If the auditd daemon is not running, then messages are written to /var/log/messages so check there too.

Also is check the path to the nginx.pid if its correct too. You might have nginx in /usr/local/nginx or in /opt or something like that.

Feldmn
  • 11
  • 1
0

Check your disk space also. I have run into a situation at times when log rotation on a VM was not working, and the only error I saw in the /var/log/messages was "ALERT exited normally with [1]". The problem was I had very little disk space remaining and it probably was not able to compress my log files. I cleaned up and it started working again.

Sid
  • 1
  • 1