DB_HOST="localhost"
DB_PORT=3306
DB_USER="root"
DB_PASS=""
maxtime=10
sql="SHOW PROCESSLIST"
sss=$(/usr/bin/mysqladmin processlist|sed -e "s/\s//g"|awk -F'|' '{print $2,$7,substr($9,1,6)}'|awk '{if($2>'"$maxtime"' && $3=="SELECT"){print $1}}')
for pid in $(echo "$sss"); do
/usr/bin/mysql -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS -e "kill $pid"
done
echo "$sss"
date
转载自:http://home.phpchina.com/space.php?uid=24549&do=blog&id=158758
DB_PORT=3306
DB_USER="root"
DB_PASS=""
maxtime=10
sql="SHOW PROCESSLIST"
sss=$(/usr/bin/mysqladmin processlist|sed -e "s/\s//g"|awk -F'|' '{print $2,$7,substr($9,1,6)}'|awk '{if($2>'"$maxtime"' && $3=="SELECT"){print $1}}')
for pid in $(echo "$sss"); do
/usr/bin/mysql -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS -e "kill $pid"
done
echo "$sss"
date
转载自:http://home.phpchina.com/space.php?uid=24549&do=blog&id=158758