Linux查看最消耗內存,CPU資源的進程

1. 查看消耗CPU資源最多的前10個進程

[root@localhost ~]# ps auxw | head -1;ps auxw |sort -rn -k3 |head -11
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1456  4.7  1.4 1128168 28884 ?       S<l  Mar30 269:35 /usr/local/vpnserver/vpnserver execsvc
root     10763  1.0  0.0 110240  1176 pts/1    R+   17:00   0:00 ps auxw
zabbix   10522  0.0  0.1  81476  2344 ?        S    Apr02   0:05 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]   
zabbix   10521  0.0  0.0  81336  1532 ?        S    Apr02   0:19 /usr/sbin/zabbix_agentd: collector [idle 1 sec]          
zabbix   10519  0.0  0.0  81336  1420 ?        S    Apr02   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       969  0.0  0.0      0     0 ?        S    Mar30   0:00 [kauditd]
root      9491  0.0  0.0 108316  1904 pts/0    Ss+  Mar31   0:00 -bash
root      9486  0.0  0.2 100060  4060 ?        Ss   Mar31   0:00 sshd: root@pts/0 
root       916  0.0  0.0      0     0 ?        S    Mar30   0:00 [ext4-dio-unwrit]
root       915  0.0  0.0      0     0 ?        S    Mar30   0:00 [jbd2/sda2-8]
[root@localhost ~]#

2. 查看消耗內存資源最多的前10個進程

[root@localhost ~]# ps auxw | head -1;ps auxw |sort -rn -k4 |head -11
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1456  4.7  1.4 1128168 28884 ?       S<l  Mar30 269:49 /usr/local/vpnserver/vpnserver execsvc
root      9486  0.0  0.2 100060  4060 ?        Ss   Mar31   0:00 sshd: root@pts/0 
root     10449  0.0  0.2 100056  4036 ?        Ss   Apr02   0:00 sshd: root@pts/1 
zabbix   10522  0.0  0.1  81476  2344 ?        S    Apr02   0:05 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]   
root      9082  0.0  0.1  12016  2276 ?        S<   Mar30   0:00 /sbin/udevd -d
root      9068  0.0  0.1  12140  2404 ?        S<   Mar30   0:00 /sbin/udevd -d
root      1426  0.0  0.1  81012  3464 ?        Ss   Mar30   0:01 /usr/libexec/postfix/master
postfix   1431  0.0  0.1  81260  3484 ?        S    Mar30   0:00 qmgr -l -t fifo -u
postfix  10748  0.0  0.1  81092  3440 ?        S    15:47   0:00 pickup -l -t fifo -u
zabbix   10521  0.0  0.0  81336  1532 ?        S    Apr02   0:19 /usr/sbin/zabbix_agentd: collector [idle 1 sec]          
zabbix   10519  0.0  0.0  81336  1420 ?        S    Apr02   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# 

3. 如下指令也是同樣效果(按照cpu,內存等)

ps auxw --sort=rss
ps auxw --sort=%cpu
ps auxw --sort=%mem

4. 幾個參數的含義

  1. %MEM 進程的內存佔用率

  2. MAJFL is the major page fault count,

  3. VSZ 進程所使用的虛存的大小

  4. RSS 進程使用的駐留集大小或者是實際內存的大小(RSS is the "resident 5. set size" meaning physical memory used)

  5. TTY 與進程關聯的終端(tty)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章