File indexing completed on 2024-04-06 11:56:35
0001
0002
0003
0004
0005 BEGIN {
0006 use File::Basename;
0007 unshift(@INC, dirname($0)."/mpslib");
0008 }
0009 use Mpslib;
0010 use warnings;
0011 use POSIX;
0012 read_db();
0013
0014 my @disabledjobs;
0015 my $count = 0;
0016 my $confname = "";
0017
0018 while (@ARGV) {
0019 my $arg = shift(@ARGV);
0020 if ($arg =~ /-N/g) {
0021 $confname = $arg;
0022 $confname =~ s/-N//;
0023 if (length($confname) == 0) {
0024 $confname = shift(@ARGV);
0025 }
0026 $confname =~ s/\s//g;
0027 if($confname =~ /\:/)
0028 {
0029 $confname =~ s/\://g;
0030 print "colons were removed in configuration name because they are not allowed: $confname\n";
0031 }
0032 }
0033 elsif ($arg eq "-h")
0034 {
0035 print 'mps_disablejob.pl [-h] [-N name] [jobids]
0036 Parameters/Options:
0037 -h The help.
0038 -N name Disable Mille jobs with name "name".
0039 jobids A list of Mille job ids which should be disabled. Does not work together with option -N.
0040
0041 The script mps_disablejob.pl can be used to disable several Mille jobs by using either their associated name or by their ids.
0042
0043 #Examples:
0044
0045 #first example:
0046 #create a new Pede job:
0047 % mps_setupm.pl
0048 # disable some Mille jobs:
0049 % mps_disablejob.pl -N ztomumu
0050 # submit the Pede job (works only if the "force" option is used):
0051 % mps_fire.py -m -f
0052 # enable everything
0053 % mps_enablejob.pl
0054
0055 #second example:
0056 #create a new Pede job:
0057 % mps_setupm.pl
0058 # disable some Mille jobs
0059 % mps_disablejob.pl 3 5 6 77 4
0060 # submit the Pede job (works only if the "force" option is used):
0061 % mps_fire.py -m -f
0062
0063 #third example:
0064 # disable a sequence of jobs
0065 % mps_disablejob.pl `seq 2 300`
0066 #create and submit new Pede job. Note if you want to omit the "force" option when the Pede job is submitted, you need to use the -a option for mps_setupm.pl.
0067 % mps_setupm.pl -a
0068 % mps_fire.py -m
0069 % mps_enablejob.pl
0070 ';
0071 exit;
0072 }
0073 else
0074 {
0075 if(isdigit $arg)
0076 {
0077 push @disabledjobs, $arg;
0078 $count++;
0079 }
0080 else
0081 {
0082 print "only integer numbers are allowed for the job ids: $arg\n";
0083 exit(-1);
0084 }
0085 }
0086 }
0087
0088 if($confname ne "")
0089 {
0090 print "Disable jobs: ${confname}.\n";
0091 for (my $i=0; $i<@JOBID; ++$i) {
0092 my $status = $JOBSTATUS[$i];
0093 if(defined $status)
0094 {
0095 unless($JOBDIR[$i] =~ /jobm/)
0096 {
0097 my $name = $JOBSP3[$i];
0098 if($name eq $confname )
0099 {
0100 $JOBSTATUS[$i] = "DISABLED".$status unless ($status =~ /DISABLED/i);
0101 }
0102 }
0103 }
0104 }
0105 }
0106 elsif($count==0)
0107 {
0108 for (my $i=0; $i<@JOBID; ++$i) {
0109 my $status = $JOBSTATUS[$i];
0110 if($status =~ /DISABLED/)
0111 {
0112 print "mps_disablejob.pl job $i is already disabled!\n";
0113 }
0114 else
0115 {
0116 if(defined $status)
0117 {
0118 unless($JOBDIR[$i] =~ /jobm/i)
0119 {
0120 $JOBSTATUS[$i] = "DISABLED".$status;
0121 }
0122 }
0123 }
0124 }
0125 }
0126 else
0127 {
0128 foreach my $j (@disabledjobs) {
0129 my $status = $JOBSTATUS[$j-1];
0130 if(defined $status)
0131 {
0132 unless($JOBDIR[$j-1] =~ /jobm/i)
0133 {
0134 if($status =~ /DISABLED/i)
0135 {
0136 print "mps_disablejob.pl job $j is already disabled!\n";
0137 }
0138 else
0139 {
0140 $JOBSTATUS[$j-1] = "DISABLED".$status;
0141 }
0142 }
0143 }
0144 else
0145 {
0146 print "job number ". ($j-1). " was not found.\n";
0147 }
0148 }
0149 }
0150 write_db();