ps -ef


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ps -ef
# 1  
Old 08-18-2005
ps -ef

Hi,

I need find some server is running or nor, if not I have to send a mail,

if I use

ps -ef | grep buyerserver1

I am getting pid etc etc...
I want validate with boolean value.. and send the mail.. how to do...
# 2  
Old 08-18-2005
I use this:

the status to get the boolean expression with pgrep.

In your script

pgrep dhcpd > /dev/null

if ( $status = 0 ) then
echo "dhcpd is running"
else
echo "it is not running"
fi
# 3  
Old 08-19-2005
pgrep is a GNU linux utility - if you do not have it then use
Code:
ps -ef | grep -q dhcpd
if [ $? -eq 0 ] ; then
  echo "dhcpd running"
else
  echo "dhcpd not running"
fi

# 4  
Old 08-19-2005
Quote:
Originally Posted by jim mcnamara
Code:
ps -ef | grep -q dhcpd
if [ $? -eq 0 ] ; then
  echo "dhcpd running"
else
  echo "dhcpd not running"
fi

with the above, there could be frequent chances where we do end up with process info that are not under specific user control.

ps -ef | grep <user> | grep -q dhcpd
# 5  
Old 08-19-2005
Quote:
ps -ef | grep <user> | grep -q dhcpd
whould be better written as:

Code:
ps -fu <user> | grep -q dhcpd

 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question