#! /bin/bash
# control ssh tunnel process script, running on centos 5/6
# ssh process greater than 20 will be killed automatically, use crontab running every 15 minutes
# by @twfcc public domain, $PROG:2much_process
list="/var/mail"
max_process=20
for i in $(ls "$list") ; do
count=$(ps aux | grep -i "$i" | grep -v grep | awk '{print $2}')
if [ -z "$count" ] ; then
continue
fi
process=($(echo "$count"))
how_many=${#process[@]}
if [ $how_many -gt $max_process ] ; then
kill $(ps aux | grep -i "$i" | grep -v grep | awk '{print $2}')
fi
done
exit 0
bash script for killing process which abuse SSH system
发布于 2013-03-30 221 次阅读
Comments NOTHING