PS grep - Monitoring Memory usage

Posted under » Ubuntu » Linux on 04 February 2010

The ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes. Users can also utilize the ps command in conjunction with the grep command to find information about one process, such as its process id.

 # ps -A | grep firefox-bin
11778 ?        02:40:08 firefox-bin
11779 ?        00:00:00 firefox-bin
 

Commonly runs with the non-standard options aux, where

Also you can add 'www' after aux, like "ps auxwww" for complete information about the process including all parameters.

 # ps axuwww | grep python
root      7587  0.4  3.4 182620 70856 pts/2    Sl+  Feb08   9:43 python /t/interfil_app.py
root     22949  0.0  0.0   3336   792 pts/0    S+   18:09   0:00 grep python
 

Obviously, we don't want the grep part to appear so to filter 'grep' out, we add -v

 # ps axuwww | grep python | grep -v grep | awk '{print $1}'
root      7587  0.4  3.4 182620 70856 pts/2    Sl+  Feb08   9:43 python /t/interfil_app.py
 

We can drill down further to just the %MEM used by using the awk command

 # ps axuwww | grep python | grep -v grep | awk '{print $4}'
3.4 
 

If you want to know how to kill a process, click here.

For more information on the headers.


web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data