Safe log rotation

oscaretu . oscaretu at gmail.com
Thu Oct 2 07:08:24 UTC 2014


I think you should  remove the line:

sleep 15

It doesnt' anything useful, It just delay the restart, so during 15 seconds
the request will end been registered in the old log file

mv /mnt/vg0-lv0/access.log /mnt/vg0-lv0/access.log.OLD
sudo kill -USR1 `cat /var/run/nginx.pid`
sleep 2
head -n 5 /mnt/vg0-lv0/access.log

If I would do this in a interactive way, I'd prefer

mv /mnt/vg0-lv0/access.log /mnt/vg0-lv0/access.log.OLD
sudo kill -USR1 `cat /var/run/nginx.pid`
sleep 2
tail -f  /mnt/vg0-lv0/access.log

because I see the log request in real time



On Thu, Oct 2, 2014 at 8:39 AM, Igor Sysoev <igor at sysoev.ru> wrote:

>
> On 02 Oct 2014, at 01:30, jmobile <nginx-forum at nginx.us> wrote:
>
> > Hi,
> >
> > I'd like to check how nginx handles command from
> > http://wiki.nginx.org/LogRotation
> > kill -USR1 `cat /var/run/nginx.pid`
> >
> > I'm using it to recreate log files during rotation.
> >
> > My question if any loglines can be lost in case time interval between
> > physical log files rotation and USR1 is large enough, like seconds? Or if
> > load is very high.
> >
> > For example, while I was sending traffic to website with "ab -n 20 -c 10
> > http://test-s.mysite.com/static/99$i/logo/test.png > /dev/null 2>&1" in
> the
> > loop, I executed on the web-server this
> >
> > tail -n 5 /mnt/vg0-lv0/access.log
> > rm -rf /mnt/vg0-lv0/access.log
> > sleep 15; sudo kill -USR1 `cat /var/run/nginx.pid`
> > sleep 2
> > head -n 5 /mnt/vg0-lv0/dj-access.log
>
> This is not log rotation but log removal. Try this:
>
> mv /mnt/vg0-lv0/access.log /mnt/vg0-lv0/access.log.OLD
> sleep 15;
> sudo kill -USR1 `cat /var/run/nginx.pid`
> sleep 2
> head -n 5 /mnt/vg0-lv0/access.log
>
>
> --
> Igor Sysoev
> Join us for nginx.conf 2014, October 20-22, San Francisco.
> Get 25% off with code NGINXUG: http://nginx.com/nginxconf/
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



-- 
Oscar Fernandez Sierra
oscaretu at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20141002/3bd01b81/attachment.html>


More information about the nginx mailing list