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 > Kill all instances of httpd daemon that are Oprhaned

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-04, 15:39
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
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>
Reply With Quote
  #2 (permalink)  
Old 02-19-04, 16:04
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: Kill all instances of httpd daemon that are Oprhaned

Quote:
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
Reply With Quote
  #3 (permalink)  
Old 02-19-04, 16:14
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
Re: Kill all instances of httpd daemon that are Oprhaned

Quote:
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 17:46.
Reply With Quote
  #4 (permalink)  
Old 02-20-04, 03:49
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Try this :
Code:
kill -9 `ps -ef | grep [h]ttp | awk 'NR>1 {print $1}'`
__________________
Jean-Pierre.
Reply With Quote
  #5 (permalink)  
Old 02-20-04, 11:53
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
Quote:
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
Reply With Quote
  #6 (permalink)  
Old 02-20-04, 12:32
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
The PID column may be different for you. Change $1 in the awk command by the right column.
__________________
Jean-Pierre.
Reply With Quote
  #7 (permalink)  
Old 02-20-04, 15:31
pranav610 pranav610 is offline
Registered User
 
Join Date: Jan 2004
Posts: 25
Quote:
Originally posted by aigles
The PID column may be different for you. Change $1 in the awk command by the right column.
Thanks worked
Reply With Quote
  #8 (permalink)  
Old 02-24-04, 04:25
doctorrossi doctorrossi is offline
Registered User
 
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]
Reply With Quote
  #9 (permalink)  
Old 02-24-04, 04:36
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
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.
Reply With Quote
  #10 (permalink)  
Old 02-24-04, 05:02
doctorrossi doctorrossi is offline
Registered User
 
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
Reply With Quote
  #11 (permalink)  
Old 02-24-04, 05:12
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
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.
Reply With Quote
  #12 (permalink)  
Old 02-24-04, 05:25
doctorrossi doctorrossi is offline
Registered User
 
Join Date: Feb 2004
Posts: 6
OK!
Merci beaucoup Jean Pierre!
Reply With Quote
  #13 (permalink)  
Old 02-25-04, 10:12
pranav610 pranav610 is offline
Registered User
 
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
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