[Pkg-nginx-maintainers] Bug#858595: Bug#858595: nginx logrotate doesn't properly switch to new logfiles

Christos Trochalakis ctrochalakis at debian.org
Mon Mar 27 10:07:28 UTC 2017


Hello Paul,

On Fri, Mar 24, 2017 at 10:14:21AM +0200, Paul Tötterman wrote:
>Package: nginx
>Version: 1.10.3-1
>Severity: normal
>
>Dear Maintainer,
>
>I noticed that access.log.1 kept growing and access.log had size 0. Clearly
>logrotate had run, but something doesn't quite work. lsof showed nginx still
>having access.log.1 open. It seems that logrotate calls
>
>    invoke-rc.d nginx rotate
>
>, which in turn calls
>
>    start-stop-daemon --stop --signal USR1 --quiet --pidfile $PID --name $NAME
>
>I tried calling invoke-rc.d nginx rotate manually, after which lsof still showed
>nginx keeping the old logfiles open.
>
>    systemctl kill -s USR1 --kill-who=main nginx.service
>
>also didn't work, and neither did the same with --kill-who=all
>
>    systemctl restart nginx
>
>did, finally, cause nginx to open the correct logfiles. But it seems unnecessary
>heavy handed for log rotation.
>
>Any better ideas?
>

Could you please run:

# lsof -p $(systemctl show -pMainPID nginx| cut -d= -f2)|grep /var/log
# invoke-rc.d nginx rotate
# lsof -p $(systemctl show -pMainPID nginx| cut -d= -f2)|grep /var/log

Also note that logrotate runs the postrotate script only when the
matching log files are not empty (notifempty flag). If those files are
empty, like in your case, the command isn't triggered.



More information about the Pkg-nginx-maintainers mailing list