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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.