[slurm-users] How to check if there's a reservation

Prentice Bisbal pbisbal at pppl.gov
Thu May 10 14:23:06 MDT 2018


Dear Slurm Users,

We've started using maintenance reservations. As you would expect, this 
caused some confusion for users who were wondering why their jobs were 
queuing up and not running. Some of my users provide a public service of 
sorts that automatically submits jobs to our cluster. They would like to 
have their submission framework automatically detect if there's a 
reservation that may interfere with their jobs, and act accordingly.

What is the best way to do this? Typically, in my shell scripts, I have 
some command that tests something, and then check exit code returned by 
the command. For example to check if my name is in file 'foo.txt', I'd 
do something like this:

grep -iq prentice foo.txt
retval=$?
if [ $retval -eq 0 ]; then
     echo "Prentice found"
else
     echo "Prentice not found"
fi
unset retval

Or something like that. I was also thinking this might work, too:

num_res=$(scontrol -o show res  | wc -l)
if [ $num_res -eq 0 ]; then
     echo "No reservations found"
else
     echo "$num_res reservation(s) found"
fi

Are there any better or other ways that you would recommend? Also, if 
there's more than one, is are they listed in any kind of order in the 
scontrol or sinfo output (soonest first, soonest last, etc.)? From the 
man page, it looks like 'scontrol show reservation' doesn't provide any 
sorting.

Prentice







More information about the slurm-users mailing list