Avr 192012
 

Créez ce script et lancez le régulièrement avec un cron :

#!/bin/bash
 
USER=root
PASS=XXXXXX
TIME=120
mysql=/usr/bin/mysql
grep=/bin/grep
mysqladmin=/usr/bin/mysqladmin
 
## KILL SLEEP > $TIME
for requete in $($mysql -u$USER -p$PASS INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where Command like "Sleep" and TIME >= "'$TIME'"'| $grep -v id); do 
       $mysqladmin -u$USER -p$PASS kill $requete 
done
 
## KILL SELECT > $TIME
for requete in $($mysql -u$USER -p$PASS INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where INFO like "select%" and TIME >= "'$TIME'"'| $grep -v id); do 
       $mysqladmin -u$USER -p$PASS kill $requete 
done