<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Hi</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">The environment variable SLURM_ARRAY_TASK_MAX might be used for this as well, e.g.:</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">    if [ $SLURM_ARRAY_TASK_ID -eq $SLURM_ARRAY_TASK_MAX ]</div><div class="gmail_default" style="font-family:monospace">    then</div><div class="gmail_default" style="font-family:monospace">       # last task</div><div class="gmail_default" style="font-family:monospace">    fi</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Though I'd caution that if you need this to run after all the jobs in the array are _complete_, you should use a job dependency.  Not sure how your scheduling is set up, but in our setup there's no guarantee that task 10 will complete before task 11.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">HTH</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Michael</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 6, 2018 at 7:40 AM, david martin <span dir="ltr"><<a href="mailto:vilanew@gmail.com" target="_blank">vilanew@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>I´m running a batch array script and would like to execute a
      command after the last task</p>
    <p><br>
    </p>
    <p>#SBATCH --array 1-10%10:1</p>
    <p>sh myscript.R inputdir/file.${SLURM_ARRAY_<wbr>TASK_ID}</p>
    <p># Would like to run a command after the last task</p>
    <p>For exemple when i was using SGE there was something like this<br>
    </p>
    <code class="m_1357790869343873821java m_1357790869343873821plain" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important;border-radius:0px!important;background:none!important;border:0px!important;float:none!important;height:auto!important;line-height:20px!important;margin:0px!important;outline:0px!important;overflow:visible!important;padding:0px!important;text-align:left!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-weight:normal!important;font-style:normal!important;font-size:14px!important;min-height:auto!important;color:rgb(0,0,0)!important"> if($SGE_TASK_ID == $SGE_TASK_LAST ) then</code>
    <div class="m_1357790869343873821line m_1357790869343873821number10 m_1357790869343873821index9 m_1357790869343873821alt1" style="margin:0px!important;padding:0px 1em 0px 0px!important;border-radius:0px!important;background:none rgb(255,255,255)!important;border:0px!important;float:none!important;height:auto!important;line-height:20px!important;outline:0px!important;overflow:visible!important;text-align:left;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-weight:400;font-style:normal;font-size:14px;min-height:auto!important;white-space:nowrap!important;color:rgb(51,51,51);font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><code class="m_1357790869343873821java m_1357790869343873821spaces" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important;border-radius:0px!important;background:none!important;border:0px!important;float:none!important;height:auto!important;line-height:20px!important;margin:0px!important;outline:0px!important;overflow:visible!important;padding:0px!important;text-align:left!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-weight:normal!important;font-style:normal!important;font-size:14px!important;min-height:auto!important">  </code><code class="m_1357790869343873821java m_1357790869343873821plain">#<span> </span></code><code class="m_1357790869343873821java m_1357790869343873821keyword" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace!important;border-radius:0px!important;background:none!important;border:0px!important;float:none!important;height:auto!important;line-height:20px!important;margin:0px!important;outline:0px!important;overflow:visible!important;padding:0px!important;text-align:left!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-weight:bold!important;font-style:normal!important;font-size:14px!important;min-height:auto!important;color:rgb(51,102,153)!important">do</code><span> </span><code class="m_1357790869343873821java m_1357790869343873821plain">last-task stuff here</code></div>
    <div class="m_1357790869343873821line m_1357790869343873821number11 m_1357790869343873821index10 m_1357790869343873821alt2" style="margin:0px!important;padding:0px 1em 0px 0px!important;border-radius:0px!important;background:none rgb(255,255,255)!important;border:0px!important;float:none!important;height:auto!important;line-height:20px!important;outline:0px!important;overflow:visible!important;text-align:left;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-weight:400;font-style:normal;font-size:14px;min-height:auto!important;white-space:nowrap!important;color:rgb(51,51,51);font-variant-ligatures:normal;font-variant-caps:normal;letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><code class="m_1357790869343873821java m_1357790869343873821plain">endif</code></div>
    <p><br>
    </p>
    <p>Can i do that with slurm ?</p>
    <p><br>
    </p>
  </div>

</blockquote></div><br></div>