Linux下查看某个进程占用的CPU及内存

目录

1.查看指定进程的PID

2.用top命令指定固定的PID

3.使用ps查询指定进程名或PID的占用情况

4.查看更详细的内存占比


1.查看指定进程的PID

ps -ef | grep iquota-server

Linux下查看某个进程占用的CPU及内存_第1张图片

2.用top命令指定固定的PID

top -p 3664

3.使用ps查询指定进程名或PID的占用情况

ps -aux | grep iquota-server

或:263539008

ps -aux | grep 3664

Linux下查看某个进程占用的CPU及内存_第2张图片

其中,

3664为PID

4.3为CPU占用百分比(注意:如果有两个CPU,32核64线程,那么总占比是6400%)

2.9为内存占用百分比,7848800为该进程使用内存(kb),总的内存可以使用top命令查看,如下:

Linux下查看某个进程占用的CPU及内存_第3张图片

4.查看更详细的内存占比

cat /proc/3664/status

返回结果:(其中VmRSS为进程所占用的内存)

Name:   java
Umask:  0022
State:  S (sleeping)
Tgid:   24852
Ngid:   0
Pid:    24852
PPid:   1
TracerPid:      0
Uid:    0       0       0       0
Gid:    0       0       0       0
FDSize: 512
Groups: 0 
NStgid: 24852
NSpid:  24852
NSpgid: 24720
NSsid:  24720
VmPeak: 22110836 kB
VmSize: 22032508 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   9972672 kB
VmRSS:   9968432 kB
RssAnon:         9947648 kB
RssFile:           20784 kB
RssShmem:              0 kB
VmData: 11418068 kB
VmStk:       140 kB
VmExe:         4 kB
VmLib:     16120 kB
VmPTE:     20780 kB
VmPMD:        96 kB
VmSwap:        0 kB
HugetlbPages:          0 kB
Threads:        96
SigQ:   3/767318
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000003
SigCgt: 2000000181005ccc
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
CapAmb: 0000000000000000
NoNewPrivs:     0
Seccomp:        0
Speculation_Store_Bypass:       vulnerable
Cpus_allowed:   ffffff,ffffffff
Cpus_allowed_list:      0-55
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000003
Mems_allowed_list:      0-1
voluntary_ctxt_switches:        1
nonvoluntary_ctxt_switches:     1

参考:https://www.cnblogs.com/EasonJim/p/8040782.html

你可能感兴趣的:(操作系统)