title: SLURM: Wait for job within job script
body: <p>I have a SLURM job script <code>a</code> which internally issues an <code>sbatch</code> call to a second job script <code>b</code>. Thus, the job <code>a</code> starts job <code>b</code>.
  Now I also have an <code>srun</code> command in job <code>a</code> which depends on the successful execution of <code>b</code>. So I did</p>
  
  <pre><code>srun -d afterok:$jobid &lt;command&gt;
  </code></pre>
  
  <p>The issue is that dependencies are seemingly not honoured for job steps which I have in this case because my <code>srun</code> runs within the job allocation <code>a</code> (see the <code>--dependency</code> section of <a href="https://slurm.schedmd.com/srun.html" rel="nofollow noreferrer">https://slurm.schedmd.com/srun.html</a>).</p>
  
  <p>The question: I really need to wait for job <code>b</code> to finish before I issue the job step. How can I do this without resorting to separate jobs?</p>