Nginx does not re-open log files on SIGUSR1.

Gena Makhomed gmm at csdoc.com
Mon Jan 3 15:01:53 MSK 2011


On 03.01.2011 13:38, Piotr Sikora wrote:

>> I think this is bug, I saw that after logrotate (which on the end
>> running SIGUSR1 on master process) my access log is empty. However if
>> I do SIGHUP it starts working. Looks like Nginx does not re-open
>> logfiles after USR1.

[...]

> $ sudo pkill -USR1 nginx

pkill send USR1 signal to all nginx processes,
not only master, but also all worker processes
in random order - it may be first workers, and last master.

if worker processes does not have write permissions
to /var/log/nginx directory - worker processes can`t
create new log files, and can't write to log files.

USR1 signal must be sent only to nginx master process
and only as postrotate script:

# cat /etc/logrotate.d/nginx

/var/log/nginx/*log {
     daily
     rotate 9
     missingok
     notifempty
     compress
     sharedscripts
     postrotate
         [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
     endscript
}

# documentation: http://sysoev.ru/nginx/docs/control.html#logs

-- 
Best regards,
  Gena



More information about the nginx mailing list