-
Notifications
You must be signed in to change notification settings - Fork 45
/
mayday.sh
executable file
·77 lines (60 loc) · 1.31 KB
/
mayday.sh
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
#!/bin/bash
# This is a bash script to delete all running jobs.
# 04/17/2014
# Arun Seetharam <[email protected]>
scriptName="${0##*/}"
function deleteJobs () {
re='^[0-9]+$'
qstat -u ${USER} | sed 1d | \
while read line
do
jobid=$(echo $line |cut -d "." -f 1);
if [[ $jobid =~ $re ]] ; then
echo "qdel $jobid";
fi
done
}
function printUsage () {
cat <<EOF
Synopsis
$scriptName [-h | --help]
Description
This is a bash script that kills all the running jobs of the executing user
It just asks for confirmation once, if true deletes ALL running jobs.
-h, --help
Brings up this help page
Author
Arun Seetharam, Genome Informatics Facilty, Iowa State University
06 April, 2014
EOF
}
while :
do
case $1 in
-h | --help | -\?)
printUsage
exit 0
;;
-*)
printf >&2 'WARNING: Unknown option : %s ... now exiting (try -h or --help) \n' "$1"
exit 0
;;
*)
break
;;
esac
done
while true; do
read -p "Do you want to kill all your running jobs? [Y/N] :" yn
case $yn in
[Yy]* )
deleteJobs
exit 0
;;
[Nn]* )
exit 0
;;
* ) echo "Please answer yes or no.";;
esac
done