Sunday, February 6, 2011

Unix command to find and kill processes

Windows have a good UI task manager to find and kill processes. But you need to do that in unix only using commands.

top
By default top command displays the processes in the order of CPU usage. When the top command is running, press M (Shift + m) to display processes sorted by memory usage.

To search for a process :
ps -eafww | grep "java"

Section of command Explanation
ps Used to find the process status.
e List information about every process now running
a List information about all processes most frequently requested: all those except process group leaders and processes not associated with a terminal
f Generate a full listing (detailed info)
ww If the info goes more than one line, display every thing.
| pipe command
grep java used to search all java processes

To Kill the process : 
kill –9 pid

Section of command Explanation
kill used to kill a process
-9 force kill
pid you can get the process id using any one of the above two commands
Hope this help…
Cool…

1 comment: