ps -ef

888.png

ps aux

5.png

使用sort对CPU占用进行排序

ps aux|sort -nr -k3

sort #排序命令
-nr #默认使用字符串排序n代表使用数值进行排序 默认从小到大排序 r代表反向排序
-k3 #以第3列进行排序

把输入第一行删除然后剩余的行参与排序并去前10位

ps aux|grep -v PID|sort -nr -k3|head -n10

666.png

如需要显示PID则先运行输出第一行然后再进行排序

ps aux|head -n1;ps aux|grep -v PID|sort -nr -k3|head -n10

同理输出内存占用多的进程,内存参数在第四行

ps aux|head -n1;ps aux|grep -v PID|sort -nr -k4|head -n10

标签: none