Memory & CPU Utilization by a particular Process/Command in Linux/UNIX

Overview :

with help of “ps” and “pidof” commads we can determine how much cpu and memory is consumed or  used by particular process and command.

Where “ps(process status)” displays information about the current active processes.Pidof  finds  the  process id’s (pids) of the named programs. It prints those id’s on the standard output.

Example:1 Show how much CPU & Memory Consumed by Chrome:

# ps -p $(pidof chrome | sed 's/\s/,/g') -o %cpu,%mem,cmd

Output of above command  :

chrome-memory-cpu

Example :2 CPU and Memory Consumed By MYSQL daemon

 # ps -p $(pidof mysqld | sed 's/\s/,/g') -o %cpu,%mem,cmd

mysql-mem-cpu

Example:3 Memory & CPU utilized by Apache Daemon-HTTPD

 # ps -p $(pidof httpd | sed 's/\s/,/g') -o %cpu,%mem,cmd

apache-mem-cpu

Leave a Reply

Your email address will not be published. Required fields are marked *