check if nginx is running 1

check if nginx is running

service nginx status

Here is what the above code is Doing:
1. We’re using the subprocess module to run the command “service nginx status”
2. We’re using the check_output() function to run the command and store the output in a variable called output
3. We’re using the if statement to check if the word “running” is in the output
4. If the word “running” is in the output, we print “nginx is running”
5. If the word “running” is not in the output, we print “nginx is not running”

Similar Posts