• Post Reply Bookmark Topic Watch Topic
  • New Topic

script to kill all instances of orphaned httpd daemon  RSS feed

 
Pranav Butala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to kill all instances of httpd daemon that are orphaned using a shell script?
if so, how?
I usually use:

./apachectl stop
ps -ef | grep httpd [to see if there are any oprhaned processes]
if yes,
kill -9 <pid> [to kill them]
Need an automated script for apache server
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leaving aside the question of why you're getting orphaned httpds (this is not normal): you may have "killall" or "pkill" on your system. Read the man pages for each. They both let you kill processes by name rather than just by pid; pkill has all sorts of other neat options.
 
Pranav Butala
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured out how to put it in a shell script:
#!/bin/bash
for pid in `ps -C httpd|sed -e 's/^\ \+//g' | grep httpd|awk '{print $1}'`
do
kill $pid
done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!