What is the best way to rotate NGINX log files ?

Darrin Chandler dwchandler at stilyagin.com
Sat Dec 8 16:40:14 MSK 2007


Note that those steps can be handled by most syslog rotating programs by
specifying either the pid file (maybe with separate config file and
crontab entry), or by adding the kill line as a custom command in the
main rotation config file. :)

For instance, on my OpenBSD systems, in newsyslog.conf after the 'flags'
fields is the field for pif file, so...

# logfile       owner:group  mode count size when flags
/.../access.log               644  9     512  *    Z      /.../nginx.pid

On Sat, Dec 08, 2007 at 12:40:17AM -0800, Mansoor Peerbhoy wrote:
> Thank you, Igor !
> 
> ----- Igor Sysoev <is at rambler-co.ru> wrote:
> | On Wed, Dec 05, 2007 at 10:41:30AM -0800, Mansoor Peerbhoy wrote:
> | 
> | > I have a question. What's the best way to rotate the NGINX log file ? We run NGINX as a Mail Proxy, and the log file grows quite large because we don't restart it very frequently.
> | > 
> | > Are there any alternatives to simply killing the NGINX process, zipping up the error log, and then restarting NGINX ?
> | 
> | Of course!
> | 
> | mv error.log error.log.0
> | kill -USR1 `cat master.nginx.pid`
> | wait 1 second and do anything with log
> | 
> | 
> | -- 
> | Igor Sysoev
> | http://sysoev.ru/en/
> | 
> | 
> 
> 

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler at stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation





More information about the nginx mailing list