When nginx is not running, /run/nginx.pid does not exist. In that case, the test command returns exit status 1. Since this is the last command executed by the lastaction script, logrotate treats it as a failure and reports:
error: error running last action script for /var/log/nginx/*.log
In my case, nginx is managed by Pacemaker and intentionally stopped on the standby node. The PID file is therefore absent by design. Log rotation itself completes, but the lastaction is still reported as failed.
A possible fix would be to use an explicit if statement:
if [ -f /run/nginx.pid ]; then
/usr/sbin/nginx -s reopen
fi
This returns success when nginx is not running, while still preserving a real failure from nginx -s reopen when the PID file exists.
Environment:
Distribution: SUSE Linux 16
nginx managed by Pacemaker
Affected file: /etc/logrotate.d/nginx
AI disclosure: I used an AI tool to help structure and phrase this report. I manually verified the configuration, exit status, timing, and proposed fix on the affected system.
Well it seems to me that nginx is a regular package for openSUSE Leap 16.0
zypper info nginx
Information for package nginx:
------------------------------
Repository : repo-oss (16.0)
Name : nginx
Version : 1.27.2-160000.6.1
Arch : x86_64
Vendor : SUSE LLC <https://www.suse.com/>
Installed Size : 2.4 MiB
Installed : Yes
Status : up-to-date
Source package : nginx-1.27.2-160000.6.1.src
Upstream URL : https://nginx.org
Summary : A HTTP server and IMAP/POP3 proxy server
Description :
nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev.
It has been running on many heavily loaded Russian sites for more than two years.
The IDPs response was missing the SAMLResponse parameter. This can be cause by inappropriate redirection, MITM behaviour, a failed login attepmt on the IDP, invalid response by the IDP, etc.
It is not possible to continue to login, either retry the IDP or use your local credentials to login.