#!/usr/bin/perl
my $i;
sub usage()
{
print "Usage: $0 ";
exit;
}
sub err_exit($)
{
print "$_[0] ";
exit;
}
if(not defined($ARGV[0]))
{
usage();
}
else
{
chomp($ARGV[0]);
}
if(-f $ARGV[0])
{
@users=`cat $ARGV[0]`;
chomp(@users);
}
else
{
err_exit("Would you please give me a filename?");
}
for($i = 0; $i <= $#users; $i ++)
{
print "$users[$i] ";
$init_info=`bacct -u $users[$i] | grep "Total CPU time" | awk '{print $5}'`;
chomp($init_info);
if($init_info =~ /.*No job was found satisfying.*/)
{
print "0 hours";
}
else
{
$time = $init_info/3600;
print "$time hours ";
}
}
阅读(2118) | 评论(0) | 转发(0) |