How to verify if nginx is running or not?
This is probably system-dependent, but this is the simplest way I've found.
if [ -e /var/run/nginx.pid ]; then echo "nginx is running"; fi
That's the best solution for scripting.
You could use lsof
to see what application is listening on port 80:
sudo lsof -i TCP:80
Looking at the requirement you have, the below command shall help:
service nginx status