Skip to content

Instantly share code, notes, and snippets.

@xinuc
Created June 11, 2016 01:19
Show Gist options
  • Select an option

  • Save xinuc/a960f980e40bef7324a01806350bc5f4 to your computer and use it in GitHub Desktop.

Select an option

Save xinuc/a960f980e40bef7324a01806350bc5f4 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
str = `passenger-memory-stats | grep "Passenger RubyApp" | grep MB | grep -v 'grep'`
rows = str.split(/\n/)
rows = rows.map {|s| s.gsub(/\s+/, ' ').gsub(/MB Passenger.*/, '').gsub(/ .* MB/, '')}
rows = rows.select{|row| pid, mem = row.split(' '); mem.to_f > 1000 }.map{|row| row.split(' ').first}
rows.each{|pid| puts "kill #{pid}"; `kill #{pid}` }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment