#!/bin/bash if [ $? -ne 0 ]; then echo "sbatch failed" exit 1 fi # first job SBATCH_OUTPUT=$(sbatch $1) PARALLEL_JOB=$(echo $SBATCH_OUTPUT | grep -oE "[0-9]+") echo $PARALLEL_JOB # second job sbatch --dependency=afterok:$PARALLEL_JOB collect.batch