O'Reilly logo

PostgreSQL High Performance Cookbook by Dinesh Kumar, Chitij Chauhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required