1、查询CUP占用量比较的的进程
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 12176 410 0.0 2441556 3004 ? Ssl 00:59 2:07 /usr/local/bin/agetty
www 12618 5.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12616 5.0 0.0 218820 14216 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=lzdloadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12631 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12630 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12629 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12628 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shipQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12627 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12626 4.0 0.0 218820 14216 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeLoadQueue --delay=0 --memory=128 --sleep=3 --tries=0
www 12625 4.0 0.0 218820 14220 ? S 00:59 0:00 /www/server/php/71/bin/php think queue:work --queue=shopeeItemQueue --delay=0 --memory=128 --sleep=3 --tries=0
看到 /usr/local/bin/agetty CPU占用量高达410%,这个就是异常进程。
2、kill -9 12176 杀死进程,会发现过一会这个进程又出现了,尝试多次发现杀不死,阿里云提交工单,回复中毒了,让我杀毒做好备份,建议我重装系统。
3、临时解决方案,做个定时任务,间隔一段时间去查杀该进程
#!/bin/bash
if [ -e '/usr/bin/agetty' ];then
rm -rf /usr/bin/aggesb
ps -aux |grep agetty | awk '/usr\/bin\/agetty/ {print $2}' | kill -9
fi
if [ -e '/usr/local/bin/agetty' ];then
rm -rf /usr/local/bin/agetty
ps -aux |grep agetty | awk '/usr\/local\/bin\/agetty/ {print $2}' | kill -9
fi
4、补充更新,如果异常进程名是随机的,那么可以直接杀死cup过高的进程,慎用,可能自己的进程也会被杀。使用前要确认自己的进程cup消耗不会高于某个值,一下是杀死cup消耗高于75%的进程
#!/bin/bash
/bin/ps axf -o "pid %cpu" | awk '{if($2>=75.0) print $1}' | while read procid
do
kill -9 $procid
sleep 30
done