Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Igor Sysoev <is-G97k7egY2jIKNkxEY4oc4w <at> public.gmane.org>
Subject: Re: Log rotation
Newsgroups: gmane.comp.web.nginx.english
Date: Tuesday 19th September 2006 22:49:17 UTC (over 10 years ago)
On Tue, 19 Sep 2006, Bob Ippolito wrote:

> It looks like nginx can do log rotation by sending it USR1, but I
> haven't seen any English mention of this outside of the source code.
> Could someone show an example of how log rotation works with nginx? Is
> there a recommended log rotation tool that can handle this style of
> log rotation? I've been using piped log processes (mostly rotatelogs)
> w/ Apache for years to handle this issue.
>
> Currently most of my nginx usage is as a proxy, so I've just turned
> access logs off.. but I would like to replace Apache in a few other
> places, so I need to have rotated logs.

When master process receives -USR1 it repopens all logs, does chown()
and chmod() (to allow unpriviliged worker processes to reopen them),
and notifies workers about reopening. Then the workers reopens its
logs too. So the old logs are available to gzip right away - you will
not lose any line. The sequence is following:

mv access_log  access_log.0
mv error_log  error_log.0
kill -USR1 master
sleep 1
gzip access_log.0
gzip error_log.0

nginx does not support piping logs.


Igor Sysoev
http://sysoev.ru/en/
 
CD: 4ms