Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-18-2005
Registered User
 
Join Date: Feb 2005
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
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...
Sponsored Links
    #2  
Old 08-18-2005
Registered User
 
Join Date: Nov 2004
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #3  
Old 08-19-2005
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,654
Thanks: 164
Thanked 645 Times in 622 Posts
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
Technorati Master
 
Join Date: Mar 2005
Location: classification algos
Posts: 3,188
Thanks: 19
Thanked 28 Times in 25 Posts
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
Sponsored Links
    #5  
Old 08-19-2005
reborg's Avatar
reborg reborg is offline Forum Advisor  
Administrator Emeritus
 
Join Date: Mar 2005
Location: Ireland
Posts: 4,464
Thanks: 0
Thanked 8 Times in 8 Posts
Quote:
ps -ef | grep <user> | grep -q dhcpd
whould be better written as:


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

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -4. The time now is 09:43 PM.