云主机被挖矿的应急脚本

  当云主机被挖矿之后,一般都不能很快清除挖矿程序,而这时你的云主机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

转载于:https://www.cnblogs.com/RottenLeaf/p/9650707.html

你可能感兴趣的:(云主机被挖矿的应急脚本)