Sometimes after nginx service restart and you’re trying to get the service status, you might get the following status code line:
Process: 10316 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
What does it mean?! Well, the start-stop-daemon it’s trying to stop the nginx gracefully, and if it timeouts, permission related issues being the most common reason, it will return status code 2
. The solution though, it’s pretty simple.
Prerequisites
- Access to Linux bash environment
- Nginx
Solution
Step 1. Instead of restarting the service, try to stop it first.
$ systemctl stop nginx
Step 2. Start it again.
$ systemctl start nginx
Step 3. Confirm the nginx status code 0
.
$ systemctl status nginx
Expected output:
Process: 10316 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
That’s it!
Conclusion
Although it’s not an issue, getting rid of status=2
red marks in the nginx status code, it’s totally understandable from a junior sysadmin standpoint.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.