Thursday, October 10, 2013

How to check whether a command is running or not?

www.unixbabuforum.inI use : 
command_1:"ps U <command name> |grep <command name>" 
to determine that command is running or not 
and i require to know command_1 have output or no 

what is shell scrip (in crontab) to check whether command_1 is written in above have output or no 
and if have not otput run this command

www.unixbabuforum.inthe following simple script may be help you 
#set -v -x 
COMMAND=vim #for example command is vim 
C=`ps -ef | grep $COMMAND | grep -v grep 2>/dev/null` 
if [ "x$C" = "x" ] 
echo $COMMAND is not running 
echo $COMMAND is running 


Post a Comment

Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM