设置top命令10秒刷新一次。
命令:top -d 10
top - 08:49:40 up 158 days, 17:57, 2 users, load average: 0.87, 0.75, 0.76
Tasks: 203 total, 1 running, 201 sleeping, 0 stopped, 1 zombie
%Cpu(s): 1.7 us, 0.8 sy, 0.0 ni, 95.9 id, 1.6 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 7733000 total, 157084 free, 7055964 used, 519952 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 390908 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6529 mysql 20 0 3272632 1.7g 884 S 3.2 23.2 4197:09 mysqld
9 root 20 0 0 0 0 S 0.2 0.0 198:45.15 rcu_sched
286 root 20 0 0 0 0 S 0.2 0.0 56:43.06 jbd2/vda1-8
1 root 20 0 191072 2932 1496 S 0.0 0.0 38:58.84 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:02.54 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 3:14.58 ksoftirqd/0
7 root rt 0 0 0 0 S 0.0 0.0 0:23.32 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 1:11.41 watchdog/0
12 root rt 0 0 0 0 S 0.0 0.0 1:05.76 watchdog/1
13 root rt 0 0 0 0 S 0.0 0.0 0:41.32 migration/1
14 root 20 0 0 0 0 S 0.0 0.0 3:46.79 ksoftirqd/1
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
17 root rt 0 0 0 0 S 0.0 0.0 1:13.70 watchdog/2
18 root rt 0 0 0 0 S 0.0 0.0 0:25.35 migration/2
19 root 20 0 0 0 0 S 0.0 0.0 3:08.45 ksoftirqd/2
21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/2:0H
22 root rt 0 0 0 0 S 0.0 0.0 1:07.31 watchdog/3
内容解释:
PID:进程的ID
USER:进程所有者
PR:进程的优先级别,越小越优先被执行
NInice:值
VIRT:进程占用的虚拟内存
RES:进程占用的物理内存
SHR:进程使用的共享内存
S:进程的状态。S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值为负数
%CPU:进程占用CPU的使用率
%MEM:进程使用的物理内存和总内存的百分比
TIME+:该进程启动后占用的总的CPU时间,即占用CPU使用时间的累加值。
COMMAND:进程启动命令名称
常用命令用法:
P:按%CPU使用率排行
T:按MITE+排行
M:按%MEM排行
cat /proc/进程ID/status
VmRSS对应的值就是物理内存占用率
ps aux|grep 进程名可以得出具体进程
还可以查看进程的status文件: cat /proc/进程号/status
显示字符中VmRSS对应的值就是物理内存占用的值