logrotate should send USR1 instead of reloading nginx #148

Closed
opened 2026-04-05 20:25:35 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @kjm33 on 12/20/2024

CloudPanel version(s) affected

2.4.2

Description

Using "/etc/init.d/nginx reload &> /dev/null || true" as postrotate command in lograte rules causes unnecessary reloading nginx for each site which leads to huge memory consumption. In my case with 244 sites, during rotating logs by logrotate RAM consumption for nginx jumps from ~2GB to 40 GB and that triggers OOM killer. According to the nginx documentation sending USR1 signal to master process is sufficient to reload log files.

How to reproduce

Running logrotate in a system with few hundred sites (e.x. 244).

Possible Solution

Replace postrotate command in logrotate commands from:
/etc/init.d/nginx reload &> /dev/null || true
to
[ ! -f /var/run/nginx.pid ] || kill -USR1cat /var/run/nginx.pid

Additional Context

No response

*Originally created by @kjm33 on 12/20/2024* ### CloudPanel version(s) affected 2.4.2 ### Description Using "/etc/init.d/nginx reload &> /dev/null || true" as postrotate command in lograte rules causes unnecessary reloading nginx for each site which leads to huge memory consumption. In my case with 244 sites, during rotating logs by logrotate RAM consumption for nginx jumps from ~2GB to 40 GB and that triggers OOM killer. According to the nginx documentation sending USR1 signal to master process is sufficient to reload log files. ### How to reproduce Running logrotate in a system with few hundred sites (e.x. 244). ### Possible Solution Replace postrotate command in logrotate commands from: `/etc/init.d/nginx reload &> /dev/null || true` to ` [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` ` ### Additional Context _No response_
MrUnknownDE added the improvementimprovementimprovement labels 2026-04-05 20:25:35 +02:00
Sign in to join this conversation.