Skip to main content

5.17) Array Jobs (cont'd)


This will run the script , array_job.sh, 100 times with each task asking for 30 minutes. The difference between each run is the value of the environment variable $SGE_TASK_ID, which is set automatically by SGE. In this example it will first take the value $SGE_TASK_ID=1, then $SGE_TASK_ID=2 etc.. The script should be written so that it can make use of this environment variable.

As a simple example consider, that the input data in organised in files called data.1, data.2 …data.100. An example script would take the form:

[bash]
#!/bin/bash
# Use current working directory and current environment
#$ -cwd -V
# request 30 minutes runtime for each tas
#$ -l h_rt=1:00:00
# array job with index 1 to 100, increment 1
#$ -t 1-100:1
# input file is data.<index>
# run program with input data, data.1, data.2 etc.
./prog data.${SGE_TASK_ID}
[/bash]