Welcome! Log In Create A New Profile

Advanced

Re: Nginx won't reopen log files.

February 11, 2011 02:52AM
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 ?


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Nginx won't reopen log files.

Michael Lustfield 2829 February 10, 2011 07:06PM

Re: Nginx won't reopen log files.

Igor Sysoev 1016 February 11, 2011 02:52AM

Re: Nginx won't reopen log files.

Michael Lustfield 849 February 12, 2011 03:56AM

Re: Nginx won't reopen log files.

Michael Lustfield 1220 February 12, 2011 04:10AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 263
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready