8

With SBATCH you can use the job-id in automatically generated output files using the following syntax with %j:

#!/bin/bash
# omitting some other sbatch commands here ... 
#SBATCH -o slurm-%j.out-%N # name of the stdout, using the job number (%j) and the first node (%N)
#SBATCH -e slurm-%j.err-%N # name of the stderr, using job and first node values

I've been looking for a similar syntax for using the job-name instead of the job-id. Does anyone have a reference for what other slurm/sbatch values can be referenced in the %j style syntax?

ctesta01
  • 909
  • 8
  • 19

1 Answers1

9

In the newest versions of SLURM there is an option %x that represents job name. See the "Changes in Slurm 17.02.1" section on the github: https://github.com/SchedMD/slurm/blob/master/NEWS

However on many current clusters the slurm version is older than that and this option is not implemented. You can view the version of the slurm scheduler on your system:

sbatch --version

However there is a workaround. You can create your own bash script, that can take a name as an argument, create a submission script that uses that name for the job name and output files and then submit it. For example, You can create a script submit.sh:

#!/bin/bash

echo "#!/bin/bash" > jobscript.sh
echo "#SBATCH -o $1-%j.out-%N" >> jobscript.sh
echo "#SBATCH -e $1-%j.err-%N" >> jobscript.sh
echo "#SBATCH -J $1" >> jobscript.sh   
#other echo commands with SBATCH options

echo "srun mycommand" >> jobscript.sh


#submit the job
sbatch jobscript.sh

And then execute it with an argument that correspond to the job name you want to give to your job:

bash ./submit.sh myJobName
Katia
  • 3,784
  • 1
  • 14
  • 27