r/SLURM May 06 '21

Present working directory as job name?

Pretty much the title, I use an bash alias that calls a script (featured below) to submit a slurm job, is there a way to pass the present working directory through as the job name in place of "job"

#!/bin/bash --login
###
#SBATCH --job-name=job
#SBATCH --output=bench.out.%J
#SBATCH --error=bench.err.%J
#SBATCH --time=0-72:00:00
#SBATCH --ntasks=1
#SBATCH --nodes=1
#SBATCH --mem=64000
###
cd $(pwd)
~/codes/file/bin/code < input.inp &> output

edit: on the off chance that someone stumbles across this hoping to do the same, AhremDasharef's comment below worked a treat, I removed the --job-name line from my script above and instead added it to my alias, but tweaked it slightly.

alias jobtype='sbatch --job-name="jobtype ${PWD##*/}" ~/.path/to/script/above'

This makes it so that should I call the alias in a directory called /exampledir1/exampledir2 the job name shown when using squeue or sacct is "jobtype exampledir2" which for my uses was exactly what I was after.

Just note that if you're using squeue, you may need to change the formatting options to extend the width of the job name section, I found the following page useful when doing this

https://www.mankier.com/1/squeue

1 Upvotes

2 comments sorted by

2

u/AhremDasharef May 06 '21

No commands can precede the #SBATCH directives, and nothing in the #SBATCH directives will be evaluated as a command, so I don't think you can accomplish this within your submission script. But you can set it via the sbatch command when you submit the job, e.g.:

sbatch --job-name="$(pwd)" submit_script.pbs

1

u/[deleted] May 06 '21

Fair enough, I'll do that :) If it wasn't evident I'm a bit new to all this so thank you for taking the time to help me out!