/
chainslurm.sh
executable file
·56 lines (46 loc) · 1.08 KB
/
chainslurm.sh
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
#!/bin/sh -f
if [ ! "$1" ]; then
echo "usage: chainslurm.sh jobid number script"
echo " set jobid -1 for no initial dependency"
exit -1
fi
if [ ! "$2" ]; then
echo "usage: chainslurm.sh jobid number script"
echo " set jobid -1 for no initial dependency"
exit -1
fi
if [ ! "$3" ]; then
echo "usage: chainslurm.sh jobid number script"
echo " set jobid -1 for no initial dependency"
exit -1
fi
oldjob=$1
numjobs=$2
script=$3
if [ $numjobs -gt "20" ]; then
echo "too many jobs requested"
exit -1
fi
firstcount=1
if [ $oldjob -eq "-1" ]
then
echo chaining $numjobs jobs
echo starting job 1 with no dependency
aout=`sbatch --parsable ${script} | cut -d';' -f1`
echo " " jobid: $aout
echo " "
oldjob=$aout
firstcount=2
sleep 3
else
echo chaining $numjobs jobs starting with $oldjob
fi
for count in `seq $firstcount 1 $numjobs`
do
echo starting job $count to depend on $oldjob
aout=`sbatch --parsable -d afterany:${oldjob} ${script} | cut -d';' -f1`
echo " " jobid: $aout
echo " "
oldjob=$aout
sleep 3
done