Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.