Nginx logrotate lastaction fails when nginx is not running

The nginx package installs the following lastaction in /etc/logrotate.d/nginx:

[ -f /run/nginx.pid ] && /usr/sbin/nginx -s reopen

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.

I reproduced the behaviour manually:

/bin/sh -c '[ -f /run/nginx.pid ] && /usr/sbin/nginx -s reopen'
echo $?

With no PID file present, this returns:

1

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.

Hi, welcome

Please be aware that these are the openSUSE forums, not the SUSE forums. These are at forums.suse.com

2 Likes

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.

@dah-mb open a bug report as described here https://en.opensuse.org/openSUSE:Submitting_bug_reports

Sorry, I’m using openSUSE Leap 16.0, not SUSE Linux.

@rawar I’m unable to login to Bugzilla :frowning: I get:

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.

Well i get the same login error with firefox and chrome. According to the ‘Status Page’ Bugzilla is operational but who knows.

Fyi the https://bugzilla.opensuse.com had a problem that is fixed now.

It now redirects to www.opensuse.org:

$ curl -v https://bugzilla.opensuse.com 2>&1 | grep location
< location: https://www.opensuse.org/

It seems there are still issues or they shut down bugzilla.

Well i do not know what is going on. But login to opensuse bugzilla works at least for me.

*.com is not existing and a wrong address…
The correct bugzilla adress is https://bugzilla.opensuse.org/

@dah-mb don’t get confused by the wrong adress given in the comment above yours. Try the correct one https://bugzilla.opensuse.org/ and it will work.

Yes sorry i typed this manual intead of copy and paste. Never the less the correct link seems to work here.

https://bugzilla.opensuse.org/show_bug.cgi?id=1274045

Thanks for your help!