"John W. Krahn" wrote:
>
> #!/usr/bin/perl -w
> use strict;
>
> my $results = '/home/danb/killemresults';
> open RES, '>>', $results or die "Cannot open $results: $!";
> print "\n" . localtime() . "\nStarting\n";
>
> for my $user ( map [ (split)[0,1,4] ], grep m|\bpts/|, `w -l` ) {
> # print RES "$user->[1]\n";
> my $pid = `ps -t $user->[1] -o pid`;
> print RES "$user->[0]\n";
> print RES "killing process id $pid on $user->[1] because minutes ";
> print RES $user->[2] =~ /:/ ? 'greater than 60' : 'equal', " $user->[2]\n";
> kill 9, $pid;
> }
Sorry, there could be multiple pids, so it should be:
for my $user ( map [ (split)[0,1,4] ], grep m|\bpts/|, `w -l` ) {
# print RES "$user->[1]\n";
my @pids = grep s/\D+//g&&/\d/, `ps -t $user->[1] -o pid`;
print RES "$user->[0]\n";
print RES "killing process id @pids on $user->[1] because minutes ";
print RES $user->[2] =~ /:/ ? 'greater than 60' : 'equal', " $user->[2]\n";
kill 9, @pids;
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]