使用 SBATCH 作业名称作为文件输出中的变量
Using SBATCH Job Name as a Variable in File Output
使用 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
我一直在寻找使用作业名称而不是作业 ID 的类似语法。有谁知道在 %j
样式语法中可以引用哪些其他 slurm/sbatch 值?
在最新版本的 SLURM 中,有一个选项 %x 表示作业名称。
请参阅 github 上的 "Changes in Slurm 17.02.1" 部分:
https://github.com/SchedMD/slurm/blob/master/NEWS
然而,在许多当前的集群上,slurm 版本比那个版本旧,并且这个选项没有实现。您可以在您的系统上查看 slurm 调度程序的版本:
sbatch --version
但是有一个解决方法。
您可以创建自己的 bash 脚本,该脚本可以将名称作为参数,创建一个使用该名称作为作业名称和输出文件的提交脚本,然后提交它。例如,
您可以创建脚本 submit.sh:
#!/bin/bash
echo "#!/bin/bash" > jobscript.sh
echo "#SBATCH -o -%j.out-%N" >> jobscript.sh
echo "#SBATCH -e -%j.err-%N" >> jobscript.sh
echo "#SBATCH -J " >> jobscript.sh
#other echo commands with SBATCH options
echo "srun mycommand" >> jobscript.sh
#submit the job
sbatch jobscript.sh
然后使用与您要赋予作业的作业名称相对应的参数执行它:
bash ./submit.sh myJobName
使用 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
我一直在寻找使用作业名称而不是作业 ID 的类似语法。有谁知道在 %j
样式语法中可以引用哪些其他 slurm/sbatch 值?
在最新版本的 SLURM 中,有一个选项 %x 表示作业名称。 请参阅 github 上的 "Changes in Slurm 17.02.1" 部分: https://github.com/SchedMD/slurm/blob/master/NEWS
然而,在许多当前的集群上,slurm 版本比那个版本旧,并且这个选项没有实现。您可以在您的系统上查看 slurm 调度程序的版本:
sbatch --version
但是有一个解决方法。 您可以创建自己的 bash 脚本,该脚本可以将名称作为参数,创建一个使用该名称作为作业名称和输出文件的提交脚本,然后提交它。例如, 您可以创建脚本 submit.sh:
#!/bin/bash
echo "#!/bin/bash" > jobscript.sh
echo "#SBATCH -o -%j.out-%N" >> jobscript.sh
echo "#SBATCH -e -%j.err-%N" >> jobscript.sh
echo "#SBATCH -J " >> jobscript.sh
#other echo commands with SBATCH options
echo "srun mycommand" >> jobscript.sh
#submit the job
sbatch jobscript.sh
然后使用与您要赋予作业的作业名称相对应的参数执行它:
bash ./submit.sh myJobName