Skip to content

Instantly share code, notes, and snippets.

@bumi
Forked from langalex/kill_all_rails.rb
Created November 5, 2008 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bumi/22367 to your computer and use it in GitHub Desktop.
Save bumi/22367 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#actually I just wanted to try forking a gist :D
exit unless ARGV.size == 1
pids = %x[ps ax|grep #{ARGV[0]}|grep -v grep].split("\n").map{|line| line.strip.scan(/^\d+/).first.to_i} - [Process.pid]
if pids.any?
system "kill #{pids.join(' ')}"
puts "killed #{pids.size} #{ARGV[0]} instance(s)"
else
puts "no rails processes found"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment