Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-07-2006, 11:31 AM   #1
closet geek
Registered: Apr 2003
Location: England
Posts: 146

Rep: Reputation: 15
Removing defunct httpd processes

I have come up with this little one liner to remove defunct httpd processes (which seem to linger forever unless I kill their parent process):

ps aux | grep defunct | egrep -v "grep|root" | awk '{print "cat /proc/" $2 "/stat"}' | sh | awk '{print $4}' | xargs kill > /dev/null 2>&1

The issue is, seemingly at random it will take down httpd full stop. I thought I could perhaps mitigate that and added the:

egrep -v "grep|root"

line to exclude the main root process of Apache from ever being included in the processes to be killed yet it has happened once again. I must stress the function does work, it works many many times then every so often kills Apache totally!

This is the message you'd expect from the Apache error logs:

[notice] caught SIGTERM, shutting down

when it happens.

Can anyone spot the probably obvious mistake I've made?


Old 07-08-2006, 09:28 AM   #2
closet geek
Registered: Apr 2003
Location: England
Posts: 146

Original Poster
Rep: Reputation: 15
No one?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
defunct processes in cron bujecas Debian 1 02-07-2006 01:59 PM
defunct processes appearing...and won't die! Axion Linux - Software 1 03-31-2004 11:43 AM
Crond running to many processes <defunct> tpfraz Linux - General 1 01-13-2004 07:03 AM
processes showing defunct jpbarto Linux - Software 2 11-05-2003 10:15 AM
httpd processes Hamma Linux - Software 16 06-01-2003 11:15 PM

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration