2

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.

Mouagip
  • 5,139
  • 3
  • 37
  • 52

2 Answers2

0

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.

dbeer
  • 6,963
  • 3
  • 31
  • 47
0

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
Vince
  • 3,325
  • 2
  • 23
  • 41