0

In SLURM, I can easily specify the files for logging in my job script:

#SBATCH --output=logs/output-%j
#SBATCH --error=logs/error-%j

Now, I use a jobscript that is generated programmatically. Whenever I submit a job, I'd like to save that jobscript as logs/jobscript-%j.

How could I do that? (The main difficulty seems to be to get %j.)

Michael
  • 7,407
  • 8
  • 41
  • 84
  • You might want to take a look at [this other question](https://stackoverflow.com/questions/43944543/slurm-job-knowing-what-node-it-is-on/) and do something similar within your script. – AndresM Aug 03 '17 at 15:37

2 Answers2

1

Within your run, $SLURM_JOB_ID gives you the job ID, %j.

ciaron
  • 1,089
  • 7
  • 15
1

When you submit the job, Slurm responds with the job ID. So capture that output (newer versions of Slurm make this easier with the option --parsable) in a Bash variable and use mv to rename the submission script as wanted; e.g.

JOBID=$(sbatch --parsable <name of submission script>)
mv <name of submission script> logs/jobscript-$JOBID
damienfrancois
  • 52,978
  • 9
  • 96
  • 110