Reputation: 7839
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
.)
Upvotes: 1
Views: 1004
Reputation: 59300
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
Upvotes: 1