2 messages in ru.sysoev.nginxRe: Log rotation
FromSent OnAttachments
Bob IppolitoSep 19, 2006 3:23 pm 
Igor SysoevSep 19, 2006 3:48 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Log rotationActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Sep 19, 2006 3:48:54 pm
List:ru.sysoev.nginx

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.