-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcqueue
executable file
·88 lines (77 loc) · 2.15 KB
/
cqueue
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# cqueue
set -euo pipefail
help() {
# Display help information
cat << EOF
cqueue - Display job queue information
Usage: cqueue [-h] [-p <partition>] [-u <username>]
Options:
-h Display help
-p Filter partitions
* Default value shows all partitions
* Multiple partitions can be specified with comma separation
-u Filter users
* Default value shows all users
* Multiple users can be specified with comma separation
Examples:
cqueue
cqueue -h
cqueue -p epyc-64
cqueue -u user1
cqueue -p main -u user1
cqueue -p main,gpu -u user1,user2
EOF
}
# Set default values for option arguments
users=""
partitions=""
# Set squeue format
format="%12i %.10u %.12j %.10P %.8T %.11M %.20R"
# Define options
while getopts ":hp:u:" option; do
case $option in
h) # display help
help
exit 0
;;
p) # select partitions
partitions=$OPTARG
if [[ $partitions =~ ^- ]]; then
echo "Error: Invalid argument to option -p" >&2
exit 1
fi
;;
u) # select users
users=$OPTARG
if [[ $users =~ ^- ]]; then
echo "Error: Invalid argument to option -u" >&2
exit 1
fi
;;
\?) # invalid argument
echo "Error: Invalid option -$OPTARG" >&2
exit 1
;;
esac
done
echo "-----------------------------------------------------------------------------------------"
echo " Job ID User Job Name Partition State Elapsed Nodelist(Reason)"
echo "------------ ---------- ------------ ---------- -------- ----------- --------------------"
if [[ -z $partitions ]]; then
if [[ -z $users ]]; then
# List all users and all partitions
squeue -h -o "$format"
else
# List specified users and all partitions
squeue -h -o "$format" -u "$users"
fi
else
if [[ -z $users ]]; then
# List all users and specified partitions
squeue -h -o "$format" -p "$partitions"
else
# List specified users and specified partitions
squeue -h -o "$format" -u "$users" -p "$partitions"
fi
fi