Skip to content

Instantly share code, notes, and snippets.

@jagira
Created June 15, 2011 08:03
Show Gist options
  • Save jagira/1026670 to your computer and use it in GitHub Desktop.
Save jagira/1026670 to your computer and use it in GitHub Desktop.
MySQL Connection Cleaner
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