在文件输出中使用 SBATCH 作业名称作为变量

cte*_*a01 8 slurm sbatch

通过 SBATCH,您可以使用以下语法在自动生成的输出文件中使用作业 ID %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
Run Code Online (Sandbox Code Playgroud)

我一直在寻找类似的语法来使用作业名称而不是作业 ID。有谁知道样式%j语法中可以引用哪些其他 slurm/sbatch 值?

Kat*_*tia 9

在最新版本的 SLURM 中,有一个选项 %x 代表作业名称。请参阅 github 上的“Slurm 17.02.1 中的更改”部分: https: //github.com/SchedMD/slurm/blob/master/NEWS

然而,在许多当前集群上,slurm 版本比该版本更旧,并且未实现此选项。您可以查看系统上 slurm 调度程序的版本:

sbatch --version
Run Code Online (Sandbox Code Playgroud)

不过,有一个解决方法。您可以创建自己的 bash 脚本,该脚本可以将名称作为参数,创建一个使用该名称作为作业名称和输出文件的提交脚本,然后提交它。例如,您可以创建一个脚本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
Run Code Online (Sandbox Code Playgroud)

然后使用与您要为作业指定的作业名称相对应的参数来执行它:

bash ./submit.sh myJobName
Run Code Online (Sandbox Code Playgroud)