On Fri, 11 Feb 2011 10:50:41 +0300
Igor Sysoev <igor@sysoev.ru> wrote:
> On Thu, Feb 10, 2011 at 06:04:41PM -0600, Michael Lustfield wrote:
> > Recently I noticed that logrotate does not actually rotate the files
> > correctly. I noticed this in 0.8.54.
> >
> > The issue seems to be that neither -USR1 or -s reopen will reopen the log
> > files after they've been rotated. I'm not sure if this specific to the
> > version packaged in Debian but I've seen it as an issue on both Ubuntu and
> > Debian.
> >
> > Below is what I tried to do to figure out what's going on...
> >
> > ### Clean slate
> > root@liber:/var/log/nginx# /etc/init.d/nginx stop
> > Stopping nginx: nginx.
> > root@liber:/var/log/nginx# rm *
> >
> > ### Start Nginx: Creates new log files
> > root@liber:/var/log/nginx# /etc/init.d/nginx start
> > Starting nginx: nginx.
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 8 access.log
> > du: cannot access `access.log.1': No such file or directory
> >
> > ### Force logrotate to run (which runs the kill -USR1)
> > root@liber:/var/log/nginx# logrotate -f /etc/logrotate.d/nginx
> >
> > ### Log files rotated
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 0 access.log
> > 8 access.log.1
> >
> > ### At this point files should already be getting written to the new file
> > ### because of the -USR1 in the logrotate script
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 0 access.log
> > 24 access.log.1
> >
> > ### To make sure the kill was run, we invoke it ourselves
> > root@liber:/var/log/nginx# kill -USR1 `cat /var/run/nginx.pid`
> >
> > ### And see that nginx still isn't using the new file
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 0 access.log
> > 48 access.log.1
> >
> > ### Using the more proper approach
> > root@liber:/var/log/nginx# nginx -s reopen
> >
> > ### We get the same thing
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 0 access.log
> > 68 access.log.1
> >
> > ### Trying a less appropriate option....
> > root@liber:/var/log/nginx# /etc/init.d/nginx reload
> > Reloading nginx configuration: nginx.
> >
> > ### It's finally reopened the files
> > root@liber:/var/log/nginx# du access.log access.log.1
> > 20 access.log
> > 68 access.log.1
> >
> >
> > Hopefully some smart people here can tell me what I'm doing wrong. :)
>
> What is in error_log ?
>
>
I realize what's going on here now... It's a permission issue that nginx can't
open the new files. It's a bit of a face to palm moment here. Thanks. :)
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel