I have a shell script that submits multiple jobs to SLURM. These jobs are submitted within the following loop:
nb_partitions=72
slurmids=() # storage of slurm job ids
for k in $(seq 1 $nb_partitions);
do
cd results/partition$k/MainFolder
ID=$(sbatch --parsable estimation.sh)
slurmids+=($ID)
cd ..
cd ..
cd ..
done
echo "Jobs are now running."
In addition to submitting the jobs, this loop also creates the array slurmids
that contains a list of the job ids for all the SLURM jobs.
Now, I have another SLURM job that I would like to submit with sbatch YY.sh
, but this job needs to wait to be submitted until all of the previous jobs finish. How can I do this? The command that comes to mind is sbatch --dependency=afterok<jobID1:jobID2:...:jobID72> YY.sh
, I'm not sure how to use my slurmids
list in the afterok
statement.
Any help would be much appreciated!