Dont reinvent the wheel. With that said, here are some pointers :) ([EMAIL PROTECTED])(23/ttyp2)(04:26pm:04/28/00)- ($:~)- ps auxwww | grep q[m]ail qmaill 1482 0.0 0.2 848 144 ? S Jan 24 1:54 splogger qmail qmailq 1485 0.0 0.1 840 68 ? S Jan 24 0:57 qmail-clean qmailr 1484 0.0 0.1 848 64 ? S Jan 24 0:38 qmail-rspawn qmails 1480 0.0 0.2 904 132 ? S Jan 24 10:43 qmail-send root 1483 0.0 0.1 844 68 ? S Jan 24 1:41 qmail-lspawn
Will ONLY return anything containing qmail, however will ignore the 'grep' command line with qmail on it, since it doesnt exactly match the criteria, because the brackets are there. Give it a try. Aside from that, debian should also contain the 'pidof' command... eg. ([EMAIL PROTECTED])(22/ttyp2)(04:26pm:04/28/00)- ($:~)- /sbin/pidof qmail-send 1480 Aside from that, there are scripts and utilities already written that do exactly what you want, my favorite would be DJB's (the author of qmail) supervise package. Can be found at: http://cr.yp.to/daemontools.html and more specifically: http://cr.yp.to/daemontools/supervise.html On Sat, 29 Apr 2000, Paul van Empelen wrote: >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) _ __ _____ __ _________ ______________ /_______ ___ ____ /______ John Gonzalez/Net.Tech __ __ \ __ \ __/_ __ `__ \/ __ /_ ___/ MDC Computers/netMDC! _ / / / `__/ /_ / / / / / / /_/ / / /__ (505)437-7600/fax-437-3052 /_/ /_/\___/\__/ /_/ /_/ /_/\__,_/ \___/ http://www.netmdc.com [---------------------------------------------[system info]-----------] 4:20pm up 94 days, 23:17, 5 users, load average: 0.05, 0.07, 0.08