Introduction to my question: I'm writing a script (In Perl) for checking if the Apache Web service is up - and if so, I want the script to check more things.
- I want the script to get the primary PID number of the Apache2 service.
- I want the script to count the amount of apache processes that are running.
I'm using the command: ps -eo pid,ppid,comm.
On my system, while I tested it, always the root process of Apache was output first & below it all of it's leas when the root process pid was as the ppid in the Apache process leafs.
My question is: Should it always be like that? or it might sometimes that Apache leaf process will be output above to the root Apache process?
Here is example to my current output, which is fine with me!
CrAzYoNi@Every1:~$ ps -eo pid,ppid,comm | grep apache
10326 1 apache2
20451 10326 apache2
20457 10326 apache2
20467 10326 apache2
20470 10326 apache2
20475 10326 apache2
20480 10326 apache2
20483 10326 apache2
20484 10326 apache2
20491 10326 apache2
20496 10326 apache2
Thanks in advance!