previous contents up next

Unix for Advanced Users

7. Viewing System Information

7.2.3 What's eating up all the CPU time/memory top

Use the top command to identify processes that currently consume the most memory and CPU time. The display is updated periodically. Press q to quit top.

top's display varies somewhat depending on which flavor of Unix you are using. It usually displays some system status information and for each process, the process number, owner, program name and memory and CPU usage as percentages or in absolute terms. Below is some sample output from top.

last pid: 22336;  load averages:  0.12,  0.11,  0.09    11:39:58
80 processes:  73 sleeping, 6 zombie, 1 on cpu
 
Memory: 256M real, 90M free, 34M swap in use, 351M swap free
 
 
  PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
21440 root       1  35   -3   12M   11M sleep   0:20  1.74% ncftpd
22336 mortimer   1  -7    0 1368K 1264K cpu/0   0:00  0.63% top
21075 root       1  34   -3 1832K 1456K sleep   0:16  0.33% ncftpd
  127 msql       1 -25    0 1640K  936K sleep 254:03  0.18% msql2d
22305 www        1  33    0 2728K 2112K sleep   0:00  0.04% httpd
22304 www        1  33    0 2728K 2112K sleep   0:00  0.04% httpd
22308 www        1  33    0 2728K 2112K sleep   0:00  0.02% httpd
22296 www        1  33    0 2728K 2112K sleep   0:00  0.02% httpd
22302 www        1  33    0 2656K 2056K sleep   0:00  0.02% httpd
  250 root       1  33    0  840K  576K sleep   0:02  0.02% utmpd
22299 www        1  33    0 2728K 2128K sleep   0:00  0.02% httpd
22298 www        1  33    0 2728K 2112K sleep   0:00  0.02% httpd
22310 root       1  34   -3 1848K 1504K sleep   0:00  0.01% ncftpd
22306 www        1  33    0 2736K 2120K sleep   0:00  0.01% httpd
22295 www        1  33    0 2728K 2112K sleep   0:00  0.01% httpd
Here, PRI is the priority that the process has in the kernel (based on a number of factors including age, size, owner, and niceness), NICE or niceness describes how the process ranks in priority before factors such as age and size are incorporated, and TIME is the number of CPU seconds that have been used by the process.

top is interactive, allowing you to change its display on the fly. Check out the manual page for details.

previous contents up next