forked from valvy/BalancerScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomate.sh
More file actions
executable file
·39 lines (35 loc) · 906 Bytes
/
automate.sh
File metadata and controls
executable file
·39 lines (35 loc) · 906 Bytes
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
#!/usr/bin/env bash
function runForever {
local LOGFILE=runs.log
date >> $LOGFILE
local run=0
while /bin/true;
do
#setting status to run
echo $run
echo $run >> $LOGFILE
run=$((run+=1))
#starting up
ansible-playbook ./ansible/start_balancing.yaml
sleep 4m
#killing everything
ansible-playbook ./ansible/stop_balancing.yaml
sleep 20s
done
}
status=`ps -efww | grep -w "runForever" | grep -v grep | grep -v $$ | awk '{ print $2 }'`
if [ ! -z "$status" ]; then
echo stop balancing
stat=$(ps aux | grep runForever)
pids=$(pgrep bash)
for i in $pids; do
if [[ $stat == *"$i"* ]]; then
kill -9 $i
fi
done
ansible-playbook ./ansible/stop_balancing.yaml
exit 1
fi
echo start balancing
export -f runForever
nohup bash -c runForever &