Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    Posts
    15

    Unanswered: 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

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •