(转)Top 查看某些或者某个进程(top -p pid)

时间:2024-04-15 21:47:33

原文:http://blog.****.net/zhangfn2011/article/details/7488746

 

TOP中只查看某个或某些进程的信息


top中使用CPU或MEM排序,还是看不到我们想了解的进程的相关信息;
这时就可以指定对某个或某些进程进行TOP信息显示;


1、查看某个进程的信息
例:mysqld的信息
(1)得到mysqld进程的pid
[root@6 ~]# pidof mysqld
21538

(2)top指定查看PID
[root@6 ~]# top -p 21538

top - 09:15:06 up 30 days, 53 min,  3 users,  load average: 0.07, 0.22, 0.23
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.0%us,  6.9%sy,  0.2%ni, 89.4%id,  0.3%wa,  0.1%hi,  0.1%si,  0.0%st
Mem:   1035140k total,   994888k used,    40252k free,   383072k buffers
Swap:  2048248k total,       80k used,  2048168k free,   237456k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                         
21538 mysql     15   0  146m  21m 4372 S  0.0  2.1   3:03.84 mysqld


2、查看某些进程的信息
例:mysqld/httpd的信息
(1)得到mysqld/httpd进程的pid
[root@6 ~]# pidof mysqld
21538

[root@6 ~]# pidof httpd
31117 31116 31115 31114

(2)top指定查看PID
[root@6 ~]# top -p 21538,31117,31116,31115,31114

top - 09:20:05 up 30 days, 58 min,  3 users,  load average: 0.37, 0.24, 0.23
Tasks:   5 total,   0 running,   5 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.0%us,  6.9%sy,  0.2%ni, 89.4%id,  0.3%wa,  0.1%hi,  0.1%si,  0.0%st
Mem:   1035140k total,   994364k used,    40776k free,   383404k buffers
Swap:  2048248k total,       80k used,  2048168k free,   237560k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                         
21538 mysql     15   0  146m  21m 4372 S  0.0  2.1   3:03.86 mysqld                                                                          
31117 apache    15   0 60036 8428 4668 S  0.0  0.8   0:00.48 httpd                                                                           
31116 apache    15   0 60308 9.9m 6288 S  0.0  1.0   0:00.48 httpd                                                                           
31115 apache    15   0 60100 8552 4756 S  0.0  0.8   0:00.48 httpd                                                                           
31114 apache    15   0 59892 6452 3060 S  0.0  0.6   0:00.41 httpd