NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Listing and Counting Processes with a Certain Name
Topic: GNU/Linux   Posted:2005-10-26
Printer Friendly: Print

spacerspacer
The -C option can be used with ps to display certain processes:

$ ps -C httpd
PID TTY          TIME CMD
726 ?        00:00:00 httpd
732 ?        00:00:00 httpd
6064 ?        00:00:00 httpd
19452 ?        00:00:00 httpd
21047 ?        00:00:00 httpd
21048 ?        00:00:00 httpd
21049 ?        00:00:00 httpd
21060 ?        00:00:00 httpd
30127 ?        00:00:00 httpd
31629 ?        00:00:00 httpd
32380 ?        00:00:00 httpd
32381 ?        00:00:00 httpd
32620 ?        00:00:00 httpd
532 ?        00:00:00 httpd
533 ?        00:00:00 httpd
544 ?        00:00:00 httpd
1699 ?        00:00:00 httpd
1774 ?        00:00:00 httpd
2686 ?        00:00:00 httpd
3427 ?        00:00:00 httpd
3429 ?        00:00:00 httpd
3430 ?        00:00:00 httpd
12571 ?        00:00:00 httpd
12573 ?        00:00:00 httpd
12574 ?        00:00:00 httpd
$ 

Run this through wc to count the processes:

$ ps -C httpd h | wc -l
24
$

The h option doesn't print the header, so the count is correct. The -l option for wc just prints the number of lines. Add this line to your .bashrc file to get an alias to count these processes:

alias ch="ps -C httpd h | wc -l";

and you can then just type ch to count the httpd processes.




Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS