Script to list httpd instances

Felix asked:

I have a RHEL7 server (no GUI) running several distinct instances of httpd (distinct PID files, not defined as services…don’t ask).

Trying to build a simple script that will tell me which of my httpd instances are actually started. If I run ps -ef | grep httpd, I get a listing that looks pretty much like I want, but I get a hit for every PID, which ends up giving me several hundred results. I’d like something that would give me one line for each instance.

Any ideas ?

My answer:


Use the existing PID files, if you have them:

ps -f $(cat pidfile1 pidfile2 pidfile3 ...)

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.