PS output: About root service & it leafs.
Hi all,
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! Quote:
Yours, Yoni D. |
I wouldn't assume it, just to be careful. Add the flags -u or -U to specify you want the root or apache/httpd owned processes.
http://linux.die.net/man/1/ps Theoretically you could just use the ppid=1 to get root owned process, but its more generic to check the user, just in case apache wasn't started by init. |
chrism01, thanks!! you really helped me.
I decided to work with the commands: Code:
ps -eo pid,ppid,comm,user --user root Code:
ps -eo pid,ppid,comm,user --user www-data Thanks a lot!! Cheers, Yoni D. |
All times are GMT -5. The time now is 07:28 PM. |