Tracking CPU consuming processes
In this recipe, we are going to use the top command to find the processes that are using a lot of CPU resources.
Getting ready
The top command is a Linux-based utility and it does not work in Unix-based systems. If you are using Solaris then use the prstat
command instead to find CPU intensive processes.
How to do it...
The usage of the top command is shown in the following snippet:
bash-3.2$top
Cpu states: 0.0% idle, 82.0% user, 18.7% kernel, 0.8% wait, 0.5% swap
Memory: 795M real, 12M free, 318M swap, 1586M free swap
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
23624 postgres -25 2 208M 4980K cpu 1:20 22.47% 94.43% postgres
15811 root -15 4 2372K 716K sleep 22:19 0.61% 3.81% java
20435 admin 33 0 207M 2340K sleep 2:47 0.23% 1.14% postgres
20440 admin 33 0 93M 2300K sleep 2:28 0.23% 1.14% postgres
23698 root 33 0 2052K 1584K cpu 0:00 0.23% 0.95% top
23621 admin 27 2 5080K 3420K sleep...