Cron idiosyncrasy
ronnie gauthier
ronnieg
Mon May 17 11:50:57 PDT 2004
>On Wed, 13 Aug 2003 19:36:02 -0400 - Joel Hammer <Joel at hammershome.com> wrote
>the following
>Re: Cron idiosyncrasy
I use the following to kill runaways. Can be set to let a heavy app alone by
increasing the loadtot and sleep time.
!/usr/bin/perl
sleep(5);
$killcomm = 'kill -9';
# 0.00 to 100.00
$loadtot = '50.00';
$exec = `ps ax -o \'pcpu pid\'`;
for $upid (split(/\n/, $exec)){
chomp($upid);
$upid =~ s/^\s+|\s+$//g;
$upid =~ s/\s+/\|/g;
($ucpu, $pid) = split(/\|/, $upid);
$pid =~ s/^\s+|\s+$//g;
if($ucpu > $loadtot){
if($ARGV[0] ne '-c'){system("$killcomm $pid");}else {system("$killcomm
$pid");}
}
else {$nerror = 1;}
}
if($nerror && $ARGV[0] ne '-c'){exit(1);}
On Wed, 13 Aug 2003 19:36:02 -0400 - Joel Hammer <Joel at hammershome.com> wrote
the following
Re: Cron idiosyncrasy
>Opera, when run on a remote X client, often hangs this thang called
>motifwrapper, which then consumes 99% of the CPU. This annoys all three
>users on this box. I think it has to do with flash, and it was supposed
>to have been fixed but it ain't in my hands so anyway:
>Running top | grep operamotifwrap is a great way to find these processes and
>kill them. (Only high consumption processes get listed with top, in my
>experience.)
>This script runs fine when invoked from the command line:
>#!/bin/bash
>for i in `/usr/bin/top -n1 | grep operamotifwrap | sed "s/ .*//"`
>do
>kill -9 $i
>done
>
>However, there is a problem using top with cron, so I thought I would
>mention it. When this script is called with cron, this error appears:
>
> tcgetattr() (undefined or something)
>
>This is fixed by including the -b flag, as suggested in the man page for
>top.
>
>Like so:
>
> for i in `/usr/bin/top -n1 -b | grep operamotifwrap | sed "s/ .*//"`
>
>Happy scripting.
>
>Joel
>
>
>
>_______________________________________________
>Linux-users mailing list
>Linux-users at linux-sxs.org
>Unsubscribe/Suspend/Etc ->
>http://www.linux-sxs.org/mailman/listinfo/linux-users
More information about the Linux-users
mailing list