If you have httpd running as a service in Centos, you can run service httpd 
status.   It will return a status code of 0 if it is running.

% service httpd status > /dev/null
Redirecting to /bin/systemctl status  httpd.service

% echo $?
0

From: Tom Browder [mailto:[email protected]]
Sent: Tuesday, February 21, 2017 7:54 AM
To: [email protected]
Subject: [users@httpd] apache run status: how to tell as non-root user (on 
*nix)?

I need to programatically determine whether httpd is running or not, whether 
I'm root or not. The only reliable way I have found is to use the system 
command 'ps -C httpd' and grep the results.

Is there a better way?

Thanks.

Best regards,

-Tom

Reply via email to