1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#!/usr/bin/env perl
# Author: Joerg Behr
#This script disables jobs with the given job numbers.
BEGIN {
use File::Basename;
unshift(@INC, dirname($0)."/mpslib");
}
use Mpslib;
use warnings;
use POSIX;
read_db();
my @disabledjobs;
my $count = 0;
my $confname = "";
while (@ARGV) {
my $arg = shift(@ARGV);
if ($arg =~ /-N/g) {
$confname = $arg;
$confname =~ s/-N//; # Strips away the "-N"
if (length($confname) == 0) {
$confname = shift(@ARGV);
}
$confname =~ s/\s//g;
if($confname =~ /\:/)
{
$confname =~ s/\://g;
print "colons were removed in configuration name because they are not allowed: $confname\n";
}
}
elsif ($arg eq "-h")
{
print 'mps_disablejob.pl [-h] [-N name] [jobids]
Parameters/Options:
-h The help.
-N name Disable Mille jobs with name "name".
jobids A list of Mille job ids which should be disabled. Does not work together with option -N.
The script mps_disablejob.pl can be used to disable several Mille jobs by using either their associated name or by their ids.
#Examples:
#first example:
#create a new Pede job:
% mps_setupm.pl
# disable some Mille jobs:
% mps_disablejob.pl -N ztomumu
# submit the Pede job (works only if the "force" option is used):
% mps_fire.py -m -f
# enable everything
% mps_enablejob.pl
#second example:
#create a new Pede job:
% mps_setupm.pl
# disable some Mille jobs
% mps_disablejob.pl 3 5 6 77 4
# submit the Pede job (works only if the "force" option is used):
% mps_fire.py -m -f
#third example:
# disable a sequence of jobs
% mps_disablejob.pl `seq 2 300`
#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.
% mps_setupm.pl -a
% mps_fire.py -m
% mps_enablejob.pl
';
exit;
}
else
{
if(isdigit $arg)
{
push @disabledjobs, $arg;
$count++;
}
else
{
print "only integer numbers are allowed for the job ids: $arg\n";
exit(-1);
}
}
}
if($confname ne "")
{
print "Disable jobs: ${confname}.\n";
for (my $i=0; $i<@JOBID; ++$i) {
my $status = $JOBSTATUS[$i];
if(defined $status)
{
unless($JOBDIR[$i] =~ /jobm/)
{
my $name = $JOBSP3[$i];
if($name eq $confname )
{
$JOBSTATUS[$i] = "DISABLED".$status unless ($status =~ /DISABLED/i);
}
}
}
}
}
elsif($count==0)
{
for (my $i=0; $i<@JOBID; ++$i) {
my $status = $JOBSTATUS[$i];
if($status =~ /DISABLED/)
{
print "mps_disablejob.pl job $i is already disabled!\n";
}
else
{
if(defined $status)
{
unless($JOBDIR[$i] =~ /jobm/i)
{
$JOBSTATUS[$i] = "DISABLED".$status;
}
}
}
}
}
else
{
foreach my $j (@disabledjobs) {
my $status = $JOBSTATUS[$j-1];
if(defined $status)
{
unless($JOBDIR[$j-1] =~ /jobm/i)
{
if($status =~ /DISABLED/i)
{
print "mps_disablejob.pl job $j is already disabled!\n";
}
else
{
$JOBSTATUS[$j-1] = "DISABLED".$status;
}
}
}
else
{
print "job number ". ($j-1). " was not found.\n";
}
}
}
write_db();
|