Bill H wrote:
> On Nov 7, 8:59 am, Bill H <b...@ts1000.us> wrote:
>
>>Is there a way in perl to watch what is running on a server and close
>>out applications that appear to be hung?
>>
>>I am running a perl bulletin board (YaBB) and have been having an
>>issue where it seems to hang occasionally and not exit, causing server
>>usage to go up to the point where the server locks up. While I am
>>trying to determine what is causing this, I would like to do is be
>>able to close an instance of the program if it is running for more
>>than 1 minute, can this be done with a perl program (maybe running as
>>a cron job)?
>>
>>Bill H
>
>
> FYI this is on a linux server
You could have your Perl program scan the output of "ps aux" and kill
all processes that have a runtime of more than 1 minute.
However, as Linux boxen often live for lengthy times, there might be
daemons which will fall into this category sooner or later, so you might
need to restrict which commands the target processes must be or must not
be running.
omy @fn = qw (USER PID CPU MEM VSZ RSS TTY STAT START TIME COMMAND);
if (open my $psuax, 'ps aux |') {
while (<$psuax>) {
next if /^USER/;
my %info;
@info{@fn} = split(/\s+/, $_, scalar @fn);
next unless $info{TIME} =~ /^0:/;
kill 9, $info{PID} if $info{COMMAND} =~ /client/;
}
close $psaux;
}
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details:
http://www.fujitsu-siemens.com/imprint.html