new file: cell2loc.py
[GalaxyCodeBases.git] / perl / etc / Jobcluster / USAGE_CHECK.pl
blobfaed0b3b0e090c641152dc68b838d1a4eb9da626
1 #!/usr/bin/perl -w
2 use strict;
3 use Getopt::Long;
4 use Cwd qw/abs_path/;
5 use FindBin qw/$Script $RealScript/;
7 my ($user_id,$script,$maxloop,$loopsleep,$help);
9 GetOptions(
10 "u=s" =>\$user_id,
11 "s=s" =>\$script,
12 "m=i" =>\$maxloop,
13 "t=i" =>\$loopsleep,
14 "h" =>\$help,
17 die "Usage:
18 \tperl $Script <-s <shell_script>> [Options]
19 Options:
20 \t-u user_id
21 \t-s shell_script at the end of your 'qsub' commend, should be absolutepath
22 \t-m the max loop time when fail to check the shell's job [3]
23 \t-t the sleep time [s] when loop [10]
24 \t-h show this help\n" if($help || !$script);
26 chomp($user_id = `whoami`) unless($user_id);
27 $maxloop ||= 3;
28 $loopsleep ||= 10;
29 #$script = abs_path($script);
31 for (my $i=0;$i<$maxloop;$i++){
32 my @job_id = `qstat -u $user_id | grep ' r ' | grep '^[0-9][0-9]' | awk '{print \$1}'`;
33 sleep $loopsleep;
34 foreach (@job_id){
35 chomp($_);
36 my $status = `qstat -j $_ 2>&1 | grep -E 'job_number|script_file|usage'`;
37 if ($status =~ /script_file.+$script/){
38 print STDERR "\n".$status."\n";
39 exit();
41 sleep 5;
43 sleep $loopsleep;
45 die "Cannot check the job of $script!\n";