![]() |
Script to kill defunct and zombie processes
Hello Friends,
While browsing the messages in this new group, I found that a couple of people tried and successful in cleaning the defunct and zombie process using a PERL or shell script. If you have a working script that cleans defuncts and zombies , could you please post it? I appreciate your help. I do not have experience with SIGNALS in PERL. Also, here is my problem: I have an apache/mysql/perl/Linux environment running cgis. My webserver runs fine for a couple of days. After a month or so, it starts running really slow (if someone try to access the URL, the response will be slow). When the webserver responses are slow, If I do ps -aef, I do see a lot of defunts. Aslo, if I do "top", I do see the zombies count as 60 - 70. I believe these defunts and zombies may be taking my webserver's resources and making it run slow. Any suggesstions? If you have a working script that cleans defuncts and zombies , could you please post it? I appreciate your help. Thank you. Sincerely, Srini |
Re: Script to kill defunct and zombie processes
>>>>> "Srini" == Srini Vuggumudi <srini@rocketmail.com> writes:
Srini> While browsing the messages in this new group, I found that a Srini> couple of people tried and successful in cleaning the defunct Srini> and zombie process using a PERL or shell script. A *defunct* or *zombie* process is a process that is already dead. The only way for it to go away is for its parent to wait() for it. So the problem cannot be solved unless the code of the program that is issuing the fork() is changed. There are many techniques for this, such as wait()ing for all kids at a choice point in a top-level loop, or the famous "double fork" trick. Also, no such thing as "PERL". Perhaps you mean "Perl" (or maybe even "perl"). print "Just another Perl hacker,"; # the first -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! |
Re: Script to kill defunct and zombie processes
Srini Vuggumudi wrote:
> Hello Friends, > > While browsing the messages in this new group, I found that a couple > of people tried and successful in cleaning the defunct and zombie > process using a PERL or shell script. > > If you have a working script that cleans defuncts and zombies , could > you please post it? I appreciate your help. I do not have experience > with SIGNALS in PERL. > > Also, here is my problem: > > I have an apache/mysql/perl/Linux environment running cgis. My > webserver runs fine for a couple of days. After a month or so, it > starts running really slow (if someone try to access the URL, the > response will be slow). When the webserver responses are slow, If I do > ps -aef, I do see a lot of defunts. Aslo, if I do "top", I do see the > zombies count as 60 - 70. I believe these defunts and zombies may be > taking my webserver's resources and making it run slow. > > Any suggesstions? > > If you have a working script that cleans defuncts and zombies , could > you please post it? I appreciate your help. > > Thank you. > > Sincerely, > > Srini a) your zombies are not using any resources becuase zombies are just processes that have terminated but still need to report their return codes to their parents. Zombies never use *any* resources except a slot in the process table, and 60 or 70 zombies aren't going to make a significant impact on it. b) You can't run a script to "clean" zombies; zombies are produced by faulty code in the parent. They will *not* go away until the parent collects their return code, normally by using some variety of wait(). You need to fix the code that forks these processes. If you're using perl to create these processes, then the NG might be able to help you debug it, but not until we see your code. c) It's perl (or Perl for the language in the abstract), not PERL. -- Christopher Mattern "Which one you figure tracked us?" "The ugly one, sir." "...Could you be more specific?" |
Re: Script to kill defunct and zombie processes
srini@rocketmail.com (Srini Vuggumudi) wrote in message news:<ac3f7819.0404291152.7256df16@posting.google. com>...
> Hello Friends, > > While browsing the messages in this new group, I found that a couple > of people tried and successful in cleaning the defunct and zombie > process using a PERL or shell script. > > If you have a working script that cleans defuncts and zombies , could > you please post it? I appreciate your help. I do not have experience > with SIGNALS in PERL. > > Also, here is my problem: > > I have an apache/mysql/perl/Linux environment running cgis. My > webserver runs fine for a couple of days. After a month or so, it > starts running really slow (if someone try to access the URL, the > response will be slow). When the webserver responses are slow, If I do > ps -aef, I do see a lot of defunts. Aslo, if I do "top", I do see the > zombies count as 60 - 70. I believe these defunts and zombies may be > taking my webserver's resources and making it run slow. > > Any suggesstions? > > If you have a working script that cleans defuncts and zombies , could > you please post it? I appreciate your help. > This works, but I wouldn't suggest you use it :~) use strict; use warnings; use IO::File; my %bad_parents; my $pipe = IO::File->new("ps -ef |") || die $!; while (my $line = <$pipe>) { if ($line =~ /^\S+\s+(\d+)\s+(\d+)\s+.*<defunct>/) { my ($pid, $ppid) = ($1,$2); print "Found zombie: $pid\n"; $bad_parents{$ppid} = 1; } } $pipe->close; while (my ($ppid,$val) = each %bad_parents) { print "Killing $ppid\n"; kill KILL=>$ppid; } > Thank you. > > Sincerely, > > Srini |
Re: Script to kill defunct and zombie processes
Bryan Castillo wrote:
> srini@rocketmail.com (Srini Vuggumudi) wrote in message > news:<ac3f7819.0404291152.7256df16@posting.google. com>... >> Hello Friends, >> >> While browsing the messages in this new group, I found that a couple >> of people tried and successful in cleaning the defunct and zombie >> process using a PERL or shell script. >> >> If you have a working script that cleans defuncts and zombies , could >> you please post it? I appreciate your help. I do not have experience >> with SIGNALS in PERL. >> >> Also, here is my problem: >> >> I have an apache/mysql/perl/Linux environment running cgis. My >> webserver runs fine for a couple of days. After a month or so, it >> starts running really slow (if someone try to access the URL, the >> response will be slow). When the webserver responses are slow, If I do >> ps -aef, I do see a lot of defunts. Aslo, if I do "top", I do see the >> zombies count as 60 - 70. I believe these defunts and zombies may be >> taking my webserver's resources and making it run slow. >> >> Any suggesstions? >> >> If you have a working script that cleans defuncts and zombies , could >> you please post it? I appreciate your help. >> > > This works, but I wouldn't suggest you use it :~) > > use strict; > use warnings; > use IO::File; > my %bad_parents; > > my $pipe = IO::File->new("ps -ef |") || die $!; > while (my $line = <$pipe>) { > if ($line =~ /^\S+\s+(\d+)\s+(\d+)\s+.*<defunct>/) { > my ($pid, $ppid) = ($1,$2); > print "Found zombie: $pid\n"; > $bad_parents{$ppid} = 1; > } > } > $pipe->close; > > while (my ($ppid,$val) = each %bad_parents) { > print "Killing $ppid\n"; > kill KILL=>$ppid; > } > > Rather like dealing with a hangnail by taking an axe to the finger. Solves the problem under consideration, but not likely to improve the overall situation... -- Christopher Mattern "Which one you figure tracked us?" "The ugly one, sir." "...Could you be more specific?" |
| All times are GMT. The time now is 04:44 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.