How to know it is the last job for a job array

Hi Team,

we are trying to developing a hook for job array, we want to cleanup some files after the last job of job array is complete.
we try to use array_id and array_index, but both do not provide the info.
could you please advise ?

Thanks.

If we submit the job qsub -J 1-100 – /bin/sleep 100 for example
Do you consider jobid[100] as the last job ? or the job that have executed at the last (the array job might have been requeued ) and the job id might be jobid[51] that has executed last.

Please check these attributes of array_job array_indices_remaining and array_indices_submitted

Thanks. we will check if it works.