aspose file tools*
The moose likes Linux / UNIX and the fly likes Kill all instances of the httpd daemon that are orphaned Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Kill all instances of the httpd daemon that are orphaned" Watch "Kill all instances of the httpd daemon that are orphaned" New topic
Author

Kill all instances of the httpd daemon that are orphaned

Pranav Butala
Greenhorn

Joined: Jan 20, 2004
Posts: 27
Is there a way to write a bash script to kill all instances of the httpd daemon that are orphaned.
Normally I use /usr/local/apache2/bin/apachectl to stop and restart apache. It cleans up all of the http processes.
Yesterday I had to manually kill them doing kill -9 pid

used:
ps -ef | grep httpd
to see the process
[ February 19, 2004: Message edited by: Pranav Butala ]
himanshu patel
Ranch Hand

Joined: Feb 03, 2003
Posts: 205
How do we know which httpd instances are orphaned?


If you want to become a rich, do not work for others but make others to work for you.
Pranav Butala
Greenhorn

Joined: Jan 20, 2004
Posts: 27
ps -ef | grep httpd
displays all the processes that are oprhaned.
eg
root 11687 116876 0 18:38 00:00:00 /usr/local/apache2/bin/httpd -k
nobody 11689 116876 0 18:38 00:00:00 /usr/local/apache2/bin/httpd -k
nobody 11690 116876 0 18:38 00:00:00 /usr/local/apache2/bin/httpd -k
etc.......
heath carlough
Ranch Hand

Joined: Feb 01, 2003
Posts: 34
you can use killall httpd
Pranav Butala
Greenhorn

Joined: Jan 20, 2004
Posts: 27
Figured out hoe to kill em:
#!/bin/bash
for pid in `ps -C httpd|sed -e 's/^\ \+//g' | grep httpd|awk '{print $1}'`
do
kill $pid
done
 
 
subject: Kill all instances of the httpd daemon that are orphaned