I am just wondering... we have a script that once in a while will hang, we have went through every line of the code, which has like 30k lines in all, it is a huge program. I had every loop of every type do a kill if it runs wild after like 100k loops, since there is nothing that should get that many loops...
Anyhow, I have tried every thing a user would do to make it hang myself and am not able to duplicate anything they do.
Once one hangs a bunch will start to hang, but even then I cannot get one to hang, so I am figuring it is a script or something that someone is running, maybe a spider attempting to index it or something. What I do in shell is run this command:
ps auxww | egrep [m]ember.cgi | awk '{print $2}' | while read PID; do
+kill -9 $PID; done
the name of the file listed in 'top' under the 'command' section is the name of the file: member.cgi
So, that is what that shell command does, it gets all those commands and kills them.
I want to set that on a cron job that runs every so often to kill any of those processes. I ran it while I had 10 people load the website and since it is only a redirect script, not one of them was interrupted by it. So I am confident that it will not hurt any visitors.
What I did was create a script for root to run:
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
`ps auxww | egrep [m]ember.cgi | awk '{print $2}' | while read PID; do
+ kill -9 $PID; done`;
print "done\n";
exit;
however, when I run it from shell:
perl root_cron.cgi
I get this error: "kill
-n signum | -sigspec pid | jobspec ... or kill -l
sigspec"
I only get that only if there are member.cgi scripts hung, if none are hung I only get the output: done
Is there a way with Perl to do this?
I am currently re-doing how the redirect script will work so I will not need this for long, I should have the whole thing re-programmed in the next 3 to 6 months, so I do need it for now.
I would really appreciate any thing you can point me to.
Thanks,
Richard