#!/usr/bin/perl $DEBUG=0; $OUTPUT=`/bin/ps arlxwh`; $date=`date`; chop $date; foreach $line (split (/\n/, $OUTPUT) ) { my $renice=0; # do nothing $line =~ s/^\s*//; ($flags, $uid, $pid, $ppid, $pri, $nice, $size, $rss, $sta, $tty, $time, @command) = split (/\s+/,$line); # Deal with the case where a field is usually missing, but isn't now if ($tty eq 'N') { $tty=$time; $time=$command[0]; } ($min,$sec) = split (/:/, $time); print "PID: $pid, NICE: $nice, TIME: $min\n" if ($DEBUG>1); $renice = 5 if ($min>29 && $min<60 && $nice <5); $renice = 10 if ($min>59 && $min<120 && $nice <10); $renice = 20 if ($min>119 && $nice <19); if ($renice>0) { print "Renicing process $pid from $nice to $renice\n" if $DEBUG; $result=`/usr/bin/renice $renice $pid`; print "$date\tPID $result" if $DEBUG; } }