I am having some syntax issues when trying to get task3 to begin only after both tasks 1 and 2 are completed. At the moment I have a chain and this is a bit inefficient for my work.
tasks:
task1=$(sbatch --parsable --job-name="${JobID1}" ${Dir}/something.sh)
sleep 2
echo ${task1}
task1=${task1}
task2=$(sbatch --parsable --dependency=aftercorr:$task1 --job-name="${JobID2}" ${Dir}/somethingelse.sh)
sleep 2
echo ${task2}
task2=${task2}
task3=$(sbatch --parsable --dependency=aftercorr:$task2 --job-name="${JobID3}" ${Dir}/somethingelse.sh)
sleep 2
echo ${task3}
task3=${task3}
Whereas I would love it if task3 would begin after both tasks 1 2 are complete. Just don't understand the syntax of slurm enough to do so.
task3=$(sbatch --parsable --dependency=aftercorr:$task1,$task2 --job-name="${JobID3}" ${Dir}/somethingelse.sh)
sleep 2
echo ${task3}
task3=${task3}
CodePudding user response:
From man sbatch
:
aftercorr:job_id[:jobid...]
A task of this job array can begin execution after the corresponding task ID in the specified job has completed successfully (ran to completion with an exit code of zero).
So you only need to put all the JobIDs separated by colons:
task3=$(sbatch --parsable --dependency=aftercorr:$task1:$task2 --job-name="${JobID3}" ${Dir}/somethingelse.sh)