当云主机被挖矿之后,一般都不能很快清除挖矿程序,而这时你的云主机cpu占用率会一直居高不下,为避免主机被锁定可先用这个脚本杀死挖矿程序,然后再来慢慢排查问题。

 

脚本内容:

#!/bin/bash

# This script is used to kill progress which having abnormal occupancy rate of CPU,

# I want through this way to protect my server from the hacker who attempting to use my server to mining.

# The method is capture PID which progress' occupancy rate of CPU greater than 90% by awk,then kill these PID.

while true;do

for i in `ps aux | awk '{if($3 > 90){print $2}}'`;do

    kill -9 $i

done

done

posted on 2018-09-15 13:17  腐叶  阅读(212)  评论(0)    收藏  举报