-
Notifications
You must be signed in to change notification settings - Fork 0
/
q-user
executable file
·61 lines (52 loc) · 996 Bytes
/
q-user
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
#!/bin/bash
#
# (@) Andre Kahles 2013
set -e
usage() {
echo "$0 [<user> -n]"
echo "-n show which nodes"
echo "use 'all' as user, to display information for all users"
exit 1
}
if [ "$1" == "-h" -o "$1" == "--help" ]
then
usage
fi
if [ -z "$1" ]
then
user="$(whoami)"
else
if [ "$1" == "-n" ]
then
user="$(whoami)"
nodes=1
else
user="$1"
fi
fi
if [ "$2" == "-n" ]
then
nodes=1
fi
if [ "$user" == "all" ]
then
users=$(qstat | grep -w R | sed -e "s/ */ /g" | cut -f 3 -d ' ' | sort -u)
else
users=$user
fi
for user in $users
do
if [ "$nodes" == "1" ]
then
running="$(qstat -t -u $user -n | grep -A 1 -w R | grep -e "^ " | cut -f 1 -d '/' | sort | uniq -c)"
else
running="$(qstat -t -u $user -n | grep -A 1 -w R | grep -e "^ " | wc -l)"
fi
echo -e "\njobs of user ${user}"
if [ -z "$running" ]
then
echo -e "\t0"
else
echo -e "$running"
fi
done