Created
January 29, 2009 15:00
-
-
Save champierre/54568 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/ruby | |
print "Specify dbname: " | |
dbname = gets.chomp | |
pids = `psql -U postgres -c "select procpid from pg_stat_activity where datname = '#{dbname}'"`.scan(/^\s+(\d+)$/) | |
pids.flatten.each do |pid| | |
print "Kill #{pid}?[yN] " | |
system "sudo kill -9 #{pid}" if gets.chomp.downcase == "y" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment