Created
June 15, 2011 08:03
-
-
Save jagira/1026670 to your computer and use it in GitHub Desktop.
MySQL Connection Cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql2' | |
# Change the host and password | |
client = Mysql::Client.new(:host => "localhost", :username => "root") | |
# Fetch running processes | |
processes = client.query("SHOW FULL PROCESSLIST") | |
processes.each do |process| | |
# Kill process | |
client.query("KILL #{process[0].to_i}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment