shell script to count httpd processes

Steve Buehler steve at ibapp.com
Mon Mar 14 19:01:43 UTC 2005


I am running RHL 7.3.
I am trying to create a shell script with /bin/sh that will count how many 
httpd processes are running at the time.
This is how it would look as a perl script:
---start of script---
#!/usr/bin/perl
$count = 0;
@hits = (`ps -afe | grep httpd | grep -v grep`);
   foreach $entry (@hits) {
     $count++;
}
print "$count\n";
---end of script---

I am trying to do this in an sh script.  Partly for learning partly because 
I want to do some other things to, but can only know how to do them in a 
shell script.  Any help would be greatly appreciated.

Thanks
Steve




More information about the redhat-list mailing list