If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to detect a process

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-04, 11:40
tcwang66 tcwang66 is offline
Registered User
 
Join Date: Feb 2002
Posts: 15
how to detect a process

How to detect a process is active or not? (for example: httpd)
I used `ps -ef | grep httpd | grep -v grep | wc -l` (if the value is greater than 0, it's active), but got some problem in assigning the value to variable. Anyone has good suggestion to solve this? Thanks for the help in advance.

tienchihwang
Reply With Quote
  #2 (permalink)  
Old 06-05-04, 09:10
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi tcwang66,
try this:

PROCESS="httpd"
ERR=`ps -ef | grep $PROCESS | grep -v "grep"`
if [ -n "$ERR" ]
then
echo $PROCESS" is running"
else
echo $PROCESS" is not running"
fi
__________________
Greetings from germany
Peter F.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On