linux+ps+-an,Linux ps 命令

Step 1.ps命令找出占用内存资源最多的20个进程

$ ps aux | head -1;ps aux |grep -v PID |sort -rn -k +4 | head -20

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

www 694 0.0 0.5 149320 94664 ? S 00:09 0:00 nginx: worker process

www 693 0.0 0.5 149320 94664 ? S 00:09 0:00 nginx: worker process

www 692 0.0 0.5 149320 95048 ? S 00:09 0:00 nginx: worker process

www 691 0.0 0.5 149320 94664 ? S 00:09 0:00 nginx: worker process

www 690 0.0 0.5 149320 94664 ? S 00:09 0:00 nginx: worker process

www 689 0.0 0.5 149320 94664 ? S 00:09 0:00 nginx: worker process

www 9961 0.0 0.1 297652 16960 ? S 00:46 0:00 sms_mt_consumer

www 9853 0.0 0.1 297652 16960 ? S 03:05 0:00 sms_mt_consumer

Step 2. 查看进程占用的实际物理内存

$ ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' |cut -d "" -f2 | cut -d "-" -f1|head -n 100

96.58 Mb nginx: worker process

96.58 Mb nginx: worker process

96.58 Mb nginx: worker process

96.58 Mb nginx: worker process

96.58 Mb nginx: worker process

96.58 Mb nginx: worker process

80.18 Mb Costar_Th_mt_consumer

80.18 Mb Costar_Th_mt_consumer

Step 3. 查看php-fpm 的物理内存

$ ps aux | grep php-fpm | grep -v grep | awk -F ' ' '{print $5,$6}'

Step 4. 查看php 平均内存使用量

ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值