如何创建函数或别名来缩短 sbatch 依赖?

问题描述 投票:0回答:1

我正在尝试编写一个函数或别名来包含在我的 .bashrc 中以缩短 sbatch --dependency=afterany:job_id jobfile

我已经尝试过了

function sbd() { sbatch --dependency=afterany:$1 $2 }

alias='sbatch --dependency=afterany:$1 $2'

alias='sbatch --dependency=afterany:'

问题是,如果我输入 1 美元的 jobID,它会尝试将其作为文件打开。我不确定如何操作,或者是否可以将其识别为 jobID。我知道 slurm 有一个变量 $SLURM_JOB_ID,但我不知道如何让我的输入被识别为这个变量,或者是否可能。感谢您的帮助!

bash slurm
1个回答
0
投票

要在 .bashrc 中创建一个函数来缩短 sbatch --dependency=afterany:job_id jobfile 命令,您可以使用以下函数:

sbd() {
    sbatch --dependency=afterany:"$1" "$2"
}

将此函数添加到 .bashrc 后,您可以通过提供作业 ID 和作业文件作为参数来使用它,如下所示:sbd job_id jobfile。

此函数正确地将第一个参数解释为作业 ID,并将其与作业文件一起传递给 sbatch,按预期处理依赖项参数。

© www.soinside.com 2019 - 2024. All rights reserved.