Hello Igor,
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 ?
Regards,
Mansoor
There is no need to kill nginx. Use logrotate or something.
On Wed, Dec 05, 2007 at 10:41:30AM -0800, Mansoor P. 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
Thank you, Igor !
----- Igor S. [email protected] wrote:
| On Wed, Dec 05, 2007 at 10:41:30AM -0800, Mansoor P. 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 S.
| Igor Sysoev
|
|
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