-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkque.sh
executable file
·47 lines (43 loc) · 1.17 KB
/
checkque.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
#!/usr/bin/env bash
cd /rsgrps/mfh4/Ariella/macsSwig_AJmodels
GOAL=$1
RESULTS=$2
echo "Check for ${GOAL} completed runs in $RESULTS"
QUEMAX=$3
PBS=$4
qstat=/cm/shared/apps/pbspro/current/bin/qstat
qsub=/cm/shared/apps/pbspro/current/bin/qsub
#check number of completed simulations
COMP=$(ls $RESULTS/ | wc -l)
echo "${COMP} runs have completed"
if [ "$COMP" -ge "$GOAL" ]; then
echo "Goal completed"
crontab -r
else
#check hrs left in group
HRS=$(va | cut -f2 | tail -1 | cut -d ":" -f1)
echo "${HRS} mfh hrs are left"
DAYS=$(( $(($(cal | wc -w) - 9)) - $(date | cut -d " " -f3) ))
echo "There are $DAYS days left in the month"
BOUND=$(( $DAYS * 350))
echo "You should leave $BOUND for the rest of the lab"
if [ "$HRS" -le "$BOUND" ]; then
echo "There are no hrs left to use"
else
#check number of jobs in que
JOBS=$($qstat | grep "agladstein" | cut -d " " -f1)
echo $JOBS
n=0
for j in $JOBS; do
q=$($qstat -t $j | grep -w "Q" | wc -l)
n=$(($n + $q))
done
echo "You have $n jobs in the que"
if [ "$n" -ge "$QUEMAX" ]; then
echo "That's enough jobs in the que"
else
echo "$qsub $PBS"
$qsub $PBS
fi
fi
fi