Greping for certain process

2007-12-25 9:34:00

Thx. for the quick responses. Responses are listed in the order I received

them. Plenty more are coming in, but number 3 worked for after slight

modification. The original posting is at the bottom. Great list!! -maa-

1.)

Dan Anderson recommended using Big Brother.

P.S. http://maclawran.ca/cgi-bin/newbb.pl

2.)

#!/bin/sh

#

# checkproc.sh

# Usage: checkproc process_name

#

PROC=`/usr/ucb/ps auxww | grep $1 | egrep -v "$0|grep" `

if [ ! "$PROC" ]

then

        echo "Process $1 not running" | mail root@yourserver.domain.org

fi

* gary franczyk

3.)

#!/bin/sh

unset TESTVAL

TESTVAL=`ps -ef | grep '[i]netd'`

if [ -n $TESTVAL ] ; then

   ps -ef | mailx -s 'inetd is not running' admin@your.host

fi;

Sweth Chandramouli

4.) My version:

unset TESTVAL

 TESTVAL=`ps -ef | grep '[i]netd'`

if [ -n $TESTVAL ] ;

then

: #do nothing

else

   ps -ef | mailx -s 'inetd is not running' mallen@aplcore.jhuapl.edu

fi;

> -----Original Message-----

> Subject: Greping for certain process

>

> Admins:

>

> Does anyone have any bourne shell code that'll grep for a certain process

> and mail the output if the process isn't running? I'll summarize.

Comments

Got something to say?

You must be logged in to post a comment.