-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathjobqos
executable file
·61 lines (57 loc) · 1.37 KB
/
jobqos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# Slurm: Change a job's QOS
# Homepage: https://github.com/OleHolmNielsen/Slurm_tools/
# List or set nice values:
listqos=0
# Default QOS
export QOS=normal
# squeue: the %q option prints QOS
# SQUEUE_FORMAT="%q %Q %T %A %P %u %g %S %e %j %b %R"
SQUEUE_FORMAT=QOS,Priority,State,JobID,Partition,UserName,Groupname,StartTime,EndTime,Name,tres-per-node,Reason
# Parse command options
while getopts "lp:q:h" options; do
case $options in
l ) listqos=1
;;
p ) export partition="-p $OPTARG"
echo "Select partition $OPTARG"
listqos=1
;;
q ) export QOS=$OPTARG
echo Set job QOS to $QOS
;;
h | * ) echo "Usage:"
echo "Listing: $0 -l [-q QOS] [-p partition]"
echo "Setting: $0 [-q QOS] job [jobs ...]"
echo "Available QOS'es are:"
sacctmgr --noheader show qos format=name
exit 1;;
esac
done
shift $((OPTIND-1))
if test $listqos -eq 0
then
JOBLIST="$*"
if test -z "$JOBLIST"
then
echo $0: No job list provided
$0 -h
exit 1
elif ! [[ ${JOBLIST} =~ ^[0-9_,]+$ ]]
then
echo ERROR: Joblist does not look like jobids:
echo $JOBLIST
exit 1
fi
echo Job list: $JOBLIST
# Change QOS of jobs
for j in $JOBLIST
do
scontrol update jobid=$j qos=$QOS
done
# Print a job status
squeue -O "$SQUEUE_FORMAT" -j `echo $JOBLIST | sed 's/ /,/g'`
else
echo; echo "Jobs with QOS=$QOS:"; echo
squeue $partition -q $QOS -O "$SQUEUE_FORMAT"
fi