ps -ef | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

ps -ef

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-18-2005
redlotus72 redlotus72 is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 7 January 2009, 5:03 PM EST
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
larryase larryase is offline
Registered User
 
Join Date: Nov 2004
Last Activity: 5 December 2010, 12:40 PM EST
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
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 16 April 2014, 7:57 AM EDT
Location: NM
Posts: 10,056
Thanks: 250
Thanked 756 Times in 711 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
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 11 April 2014, 1:02 AM EDT
Location: classification algos
Posts: 3,203
Thanks: 19
Thanked 30 Times in 27 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
Last Activity: 29 March 2012, 7:00 PM EDT
Location: Ireland
Posts: 4,464
Thanks: 0
Thanked 10 Times in 10 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 08:55 PM.