shellslurm

Save slurm job ID as you submit the job with sbatch


Is there a way to submit a job to slurm with sbatch and record the job id into a variable?

job_id = sbatch --account my_account some_script.sh

echo $job_id

17210254

Solution

  • This can be done with --parsable

    job_id=$(sbatch --parsable test.sh)
    echo $job_id
    17211434