MULTIPLE JOB SUBMISSION
There are many times when users may need to execute their programs multiple times, particularly when random number generation is being used.
Some general notes:
- The variable
$SLURM_SUBMIT_DIR
indicates the directory where the Slurm script file is located and launched from. - The program executable hello.exe is a simple “Hello World” program and can be replaced with your own executable files.
- The “email user” section within the Slurm submission has been purposely removed – as you don’t want to have 10 emails sent to you each time you run this script.
- You can change the number of times you would like the program to execute by simple changing the “
for ((i=1; i<=10; i+=1))
” and replacing the 10 value with a value of your choice. - The “jobname” will be set to
Multi-Job_[$1]
, where $1 is the job number. You may wish to change the jobname to something different.
The details for this script can be found below:
multi-submit.slurm
#!/bin/bash
for ((i=1; i<=10; i+=1))
do
jobname=Multi-Job_$i
cat << EOF | sbatch
###### Select resources #####
#SBATCH -J $jobname
#SBATCH -c 1
#SBATCH -mem=1g
#
##### Queue #####
#SBATCH -q workq
#
########## Output File ##########
#SBATCH -o \$SLURM_SUBMIT_DIR/$jobname.txt
#
########## Error File ##########
#SBATCH -e \$SLURM_SUBMIT_DIR/$jobname.err
#
##### Change to current working directory #####
cd \$SLURM_SUBMIT_DIR
#
##### Execute Program #####
./hello.exe
#
EOF
#
done