[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

grepping in ps output



Hi,

I am working on a bourne script that can restart services if they hang.
If the process does not respond, I want to kill and restart it, but I 
haven't found a good way to locate it's process ID from the ps output. 
And not all processes use a /var/run/<file>.pid.  With the commands
ps ax | grep process, you sometimes see the 'grep process' in the output. 
That's not what I want.

The following command works pretty well on Solaris. Does anybody know
the Debian equivalent?

PID=`ps $PSOPTION | grep $SERVICE| sed -e 's/^  *//' -e 's/ .*//'`
(where $PSOPTION is -e for Solaris, and probably ax for Linux)

Thanks,

Paul.


Reply to: