Having qmail running on multiple machines (I know there are better alternatives) we often have to go in and clean up after a crashed qmail service so it will behave again for a while.
Here is a quick and dirty hack to kill processes up that are there when you do a ps aux | grep <process name>
SEARCH='qmail' ; ps -eo pid,cmd | grep $SEARCH | awk '{ print $1 }' | xargs -I pid kill -15 pid
This uses ps and grep to find the processes and awk and xargs to create and execute the kill command for the PID of that process.
This command can easily be adapted to search for whatever process is required by changing the string in the SEARCH variable at the start of the command. The command above is designed as a follow up to using a ps aux | grep to find the search string that identifies the process.
Check out a quick howto on xargs here. I think it is one of the must for all hardcore Linux sys admins out there.


