Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2004
    Posts
    25

    Unanswered: Kill all instances of httpd daemon that are Oprhaned

    Is there a way to write a shell acript that will kill all the instances of httpd daemon that are orphaned.

    Usually use /usr/local/apache2/bin/apachectl to stop and restart server

    It did not work and had to use kill -9 <pid>

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: Kill all instances of httpd daemon that are Oprhaned

    Originally posted by pranav610
    Is there a way to write a shell acript that will kill all the instances of httpd daemon that are orphaned.

    Usually use /usr/local/apache2/bin/apachectl to stop and restart server

    It did not work and had to use kill -9 <pid>
    killall -9 httpd

  3. #3
    Join Date
    Jan 2004
    Posts
    25

    Re: Kill all instances of httpd daemon that are Oprhaned

    Originally posted by ika
    killall -9 httpd

    is there a way to put this in a shell script and automate the proess?

    i used:

    ps -ef | grep http

    to see the process

    if yes, how
    Last edited by pranav610; 02-19-04 at 18:46.

  4. #4
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Try this :
    Code:
    kill -9 `ps -ef | grep [h]ttp | awk 'NR>1 {print $1}'`
    Jean-Pierre.

  5. #5
    Join Date
    Jan 2004
    Posts
    25
    Originally posted by aigles
    Try this :
    Code:
    kill -9 `ps -ef | grep [h]ttp | awk 'NR>1 {print $1}'`
    nope

    bash: kill: nobody: no such pid

  6. #6
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    The PID column may be different for you. Change $1 in the awk command by the right column.
    Jean-Pierre.

  7. #7
    Join Date
    Jan 2004
    Posts
    25
    Originally posted by aigles
    The PID column may be different for you. Change $1 in the awk command by the right column.
    Thanks worked

  8. #8
    Join Date
    Feb 2004
    Posts
    6
    Hi,
    sorry for my english..
    For me a command that you explain , kill all the process's daemon http, not only a "orphaned process".
    Where it's the part that find the orphaned PID?
    I'm interested in a command that identified a httpd process without father.
    Thanks
    bash: kill: nobody: no such pid [/SIZE][/QUOTE]

  9. #9
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    if "orphaned process" is a process without father (parent pid = 1), you can do :

    Code:
    kill -9 `ps -ef | grep [h]ttp | awk 'NR>1 && $3==1 {print $2}'`
    $1 = User
    $2 = Pid
    $3 = PPid
    Jean-Pierre.

  10. #10
    Join Date
    Feb 2004
    Posts
    6
    Hi,
    but when i start my httpd server in my unix(HP-UX), with user root (httpd listen port 80, and root it's the onlyone authorized) they are always a process with ppid =1:

    root 16275 1 0 Feb 19 ? 0:55 /u09/app/oracle/9ias/Apache/Apache/bin/httpd -d /u09/app/oracle

    If i kill this, all httpd down!

    Thanks

  11. #11
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Exclude root processes :

    Code:
    kill -9 `ps -ef | grep [h]ttp | awk 'NR>1 && $1 != "root" && $3==1 {print $2}'`
    or

    Code:
    ps -ef | awk 'NR>1 && $0 ~ /[h]ttp/ && $1 != "root" && $3==1 {print $2}' | xargs kill -9
    Jean-Pierre.

  12. #12
    Join Date
    Feb 2004
    Posts
    6
    OK!
    Merci beaucoup Jean Pierre!

  13. #13
    Join Date
    Jan 2004
    Posts
    25

    Figured out how to do it

    Following is a bash script to kill htpd

    #!/bin/bash
    for pid in `ps -C httpd|sed -e 's/^\ \+//g' | grep httpd|awk '{print $1}'`
    do
    kill $pid
    done

Posting Permissions

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