Is it possible to get the number of tasks for a submitted array job? Like $SGE_TASK_ID
for the task number.
For example if I submit the job
qsub -t 1-4 my_script.sh
I'd like to get 4
.
Is it possible to get the number of tasks for a submitted array job? Like $SGE_TASK_ID
for the task number.
For example if I submit the job
qsub -t 1-4 my_script.sh
I'd like to get 4
.
I don't know of any automatic variable to do that, but I can think of a way to do this via TORQUE (I'm betting that the same arguments work for SGE or have corresponding arguments). Unfortunately, you'd have to do it manually:
qsub -t 1-4 my_script.sh -v TOTAL_TASKS=4
Then, within the job script you'll have the environment variable $TOTAL_TASKS set as desired. This doesn't give it to you automatically but it will give you the information you need.
I can obtain this information from qstat -j <job_id>
.
For example, submit some array jobs:
echo "sleep 60" | qsub -t 1-200
Use qstat to extract total tasks:
qstat -j <job_id> | grep tasks
grep
returns the following:
job-array tasks: 1-200:1