Occasionally recurring jobs will get hung, especially with jobs fired off from cron that are scheduled to run every minute. In my case there is a job that runs every minute to pick up status files from numerous remote servers, the script gets the files, parses them, and then plugs them into a MySQL database. That data is later parsed on demand by a php page to display different status information about the remote servers. All in all it works quite well, until something gets hung, especially if the NFS mount for the database has a hiccup, once the first database connect hangs it tends to hang the subsequent jobs as well... quickly filling up the available memory and of course crashes or hangs any other web pages trying to access the database.

A quick and dirty way to right things without typing or copy/pasting a bazillion pids to a kill -9

CODE:
  1. for pid in ` ps -ef |grep process_name | awk '{print $2}'`
  2. do 
  3. kill -9 $pid
  4. done

Nothing magical about it, the for loop scans the output from the ps command for the process_name, awk parses out the pid #, the loop performs a kill -9 for each pid returned.
Like I mentioned, nothing magical about it, but a quick efficient method of killing what can be hundreds of processes.

Happy hacking!