[svlug] Process watchdog

Brian J. Tarricone bjt23 at cornell.edu
Fri May 2 14:27:07 PDT 2008


Brian J. Tarricone wrote:

> something like `ps -e | grep tomcat | head -n 1 | awk '{ print $1 }'` 

Silly me, how wasteful:

`ps -e | awk '/tomcat/{ print $1 }' | head -n 1`

Or simply:

`pgrep tomcat | head -n 1`

I'm sure someone else knows some awk magic to discard all but the first 
match.  Actually, I guess that's not even necessary... passing all the 
PIDs to kill should be fine.

	-brian



More information about the svlug mailing list