MySQL: Kill sleeping connections using script

Kill Sleep Queries

It’s all too common for me to come across a box that is hopelessly overloaded with Apache requests and MySQL queries. Sometimes, it takes some brute force to keep the whole box from going under. When all else fails, I use the following one-liner to kill off all of those queries that have been running for too long.

mysql> select concat('KILL ',id,';') from information_schema.processlist where Command =    'Sleep'   and Time > 60 into outfile '/tmp/sleep_processes.txt'"
mysql> source /tmp/sleep_processes.txt

Comments

sadas said…
very nice post i am interested your post
website designing company in india

Popular posts from this blog

How do I Use the Linux Top Command?

IOPS measurement