shell script to count httpd processes

Smith, Albert Albert.Smith at genexservices.com
Thu Mar 17 00:06:58 UTC 2005



 

> -----Original Message-----
> From: redhat-list-bounces at redhat.com 
> [mailto:redhat-list-bounces at redhat.com] On Behalf Of Schott, 
> Erik J Mr ANOSC/FCBS
> Sent: Wednesday, March 16, 2005 4:05 PM
> To: me at gavitron.com; General Red Hat Linux discussion list
> Subject: RE: shell script to count httpd processes
> 
> What is this, guys?  A rerun of "Name That Tune"?
> 
> -----Original Message-----
> From: Gavin McDonald [mailto:gavitron at gmail.com]
> Sent: Wednesday, March 16, 2005 1:57 PM
> To: General Red Hat Linux discussion list
> Subject: RE: shell script to count httpd processes
> 
> 
> Well, if you're on that bent, why not do
> 
> pgrep -f /usr/sbin/httpd |wc -l
> 
> if all you want is a count...  :)
> 
> (Granted, pgrep is not available on _all_ systems.)
> 
> Regards,
> -G
> 
> -----Original Message-----
> From: redhat-list-bounces at redhat.com
> [mailto:redhat-list-bounces at redhat.com]On Behalf Of Steve Kozakoff
> Sent: Wednesday, March 16, 2005 12:40 PM
> To: redhat-list at redhat.com
> Subject: RE: shell script to count httpd processes
> 
> 
> Why not cut out the middleman too...
> 
> ps -afe | grep /usr/sbin/httpd | grep --count -v grep
> 
> -Steve
> 
> >>> PCampbell at ourvacationstore.com 3/16/2005 14:26 >>>
> What about ps -afe | grep /usr/sbin/httpd | grep -v grep| wc -l
> 
> K.i.s.s.
> 
> --
> Patrick Campbell
> OurVacationStore.com
> Website Administrator
> Tel. 602.896.4729
> 
> -----Original Message-----
> From: redhat-list-bounces at redhat.com
> [mailto:redhat-list-bounces at redhat.com]
> On Behalf Of Steve Kozakoff
> Sent: Monday, March 14, 2005 3:22 PM
> To: redhat-list at redhat.com
> Subject: RE: shell script to count httpd processes
> 
> I would recommend looking for the full path, in case (like 
> me) you have other things with the string "httpd" in the name.
> 
> for i in `ps -afe | grep /usr/sbin/httpd | grep -v grep | awk 
> '{print $2}'` do
>         COUNT=$((COUNT+1))
> done
> echo $COUNT
> 
> (Another) Steve
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 
> 

You can also do:

ps -ef|grep -e www -e httpd |grep -v grep |wc -l

Some webservers use www instead of httpd but mind you that this check's
for everything with www and/or httpd so if you have a user named WWW and
it's running another process that will be included in this return.

Albert Smith
Sr. Unix Systems Administrator
HPCSA, RHCT
Genex Services
440 E. Swedesford Rd.
Wayne, PA 19087
albert.smith at genexservices.com
(610) 964-5154





More information about the redhat-list mailing list