云主机被挖矿的应急脚本

#!/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

猜你喜欢

转载自my.oschina.net/u/3849152/blog/1809510