#!/bin/sh RAILS_PROCS=$(pgrep -f "Rails") if [ -n "$RAILS_PROCS" ] ; then # Kill once using regular kill... for i in "$RAILS_PROCS" ; do kill $i done # Wait 5 seconds and SIGKILL if they're still around... sleep 5s for i in "$RAILS_PROCS" ; do kill -9 $i done fi