title: slurm: write exit code or job status into logfile when finished (completed or failed)
body: <p>I need to make sure that all commands in my script finished successfully (returned 0 status). That's why my slurm script includes following lines:</p>
  
  <pre><code>set -e
  set -x
  </code></pre>
  
  <p>Now I would like the exit status of the whole script to be written in the logfile that's automatically created by slurm. I have tried echo <code>$SLURM_JOB_EXIT_CODE</code> (with no success) or <code>echo $?</code> (which I am not sure is what I need) as a last line of my script. </p>
  
  <p>What's the proper way to do this? I need to differentiate between "failed" and "completed" jobs, preferably by checking logfiles only.</p>