Mostly from: https://hpc.nih.gov/docs/job_dependencies.html .

Define a Bash function like:

function sb() {
    jid=$(sbatch $@  | cut -d' ' -f 4)
}

which stores the ID of the last slurm job in variable jid. Then invoking sb like follows sequence jobs, i.e., the next one will not start until the last has finished:

sb -d $jid ./myslurmjob.sh