#!/usr/local/bin/perl # myjobs: report on your jobs running on cluster and count # running. # requires Unix "ruptime" to work. # Usage: myjobs [-nr] [-help] [host ...] # If no hosts specified, reports for all cluster machines. # -nr implies don't list the number of "real" jobs at end. # Examples: # myjobs # myjobs wren puffin eagle chop($me = `whoami`); # select 2 lines to match your situation: $RSH="remsh"; # SVR4-ish $PS= "ps -u $me"; # #$RSH="rsh"; # BSD-ish #$PS= "ps x"; # $helpline = '25'; $NoReal = ''; if ( $ARGV[0] =~ /^-help/ ) { system "head -$helpline $0"; exit 0; } elsif ( $ARGV[0] =~ /^-nr/ ) { $NoReal = 'True'; shift; } open(LIST,"ruptime | awk '{print \$1, \$7}' | sort -n -r +1 |"); $count = '0'; while () { chop; chop; ($name,$load) = split(' ',$_); if ( $#ARGV != -1 ) { $Next = 'True'; foreach (@ARGV) { $Next = '' if /$name/; } next if $Next; } print "$name: (load=$load) "; if( $load ne '') { $out = `$RSH $name ps -u $me | egrep -v 'tcsh|TTY|ps|grep|remsh|myjobs|rsh|defunct'`; if ( $out =~ /^\s*$/ ) { $out = "No jobs\n"; } else { $count++; } print "$out"; } else { print "\n"; } } print "\nTotal number of \"real\" jobs: $count\n\n" unless $NoReal; exit 0;