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?
Job array's minimum ID (index) number. A full list of environment variables for SLURM can be found by visiting the SLURM page on environment variables.
Advanced Slurm: Execution: sbatch. sbatch is a means of asynchronously submitting a batch file (from which tasks will be executed) to execute on allocated resources.
The values of SLURM_PROCID range from 0 to the number of running processes minus 1. Similarly, SLURM_NTASKS contains the total number of tasks (equivalent to the value specified by -n ). By using these two variables, it is possible for tasks launched this way to divide up a workload, or implement parameter sweeps.
The srun command is designed for interactive use, with someone monitoring the output. The output of the application is seen as output of the srun command, typically at the user's terminal. The sbatch command is designed to submit a script for later execution and its output is written to a file.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With