[slurm-users] LAST TASK ID

Michael Gutteridge michael.gutteridge at gmail.com
Tue Feb 6 08:53:12 MST 2018


Hi

The environment variable SLURM_ARRAY_TASK_MAX might be used for this as
well, e.g.:

    if [ $SLURM_ARRAY_TASK_ID -eq $SLURM_ARRAY_TASK_MAX ]
    then
       # last task
    fi

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.

HTH

Michael



On Tue, Feb 6, 2018 at 7:40 AM, david martin <vilanew at gmail.com> wrote:

> Hi,
>
> I´m running a batch array script and would like to execute a command after
> the last task
>
>
> #SBATCH --array 1-10%10:1
>
> sh myscript.R inputdir/file.${SLURM_ARRAY_TASK_ID}
>
> # Would like to run a command after the last task
>
> For exemple when i was using SGE there was something like this
>  if($SGE_TASK_ID == $SGE_TASK_LAST ) then
>   # do last-task stuff here
> endif
>
>
> Can i do that with slurm ?
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schedmd.com/pipermail/slurm-users/attachments/20180206/be72c9f0/attachment.html>


More information about the slurm-users mailing list