Skip to content

Instantly share code, notes, and snippets.

@dip00dip
Created May 15, 2012 12:28
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dip00dip/2701387 to your computer and use it in GitHub Desktop.
Save dip00dip/2701387 to your computer and use it in GitHub Desktop.
kill all leaking rails processes runnning via passenger
# every 5 minutes run this script ↓
*/12 * * * * /path/to/kill_memleaked_rails.sh
#!/bin/sh
# Kill every passenger spawned rails instance with more than 350M memory usage
# don't forget to chmod+x on this file
# put it to /usr/local/bin or your rails user homedir i.e ~/bin/
for i in `passenger-memory-stats |grep current|awk '{if ($2 > 350) print $1}'` ; do kill -9 $i; done
@spight-zz
Copy link

Your simple grep into awk slays me. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment