-
Notifications
You must be signed in to change notification settings - Fork 2
/
micro-cron.sh
executable file
·81 lines (53 loc) · 1.01 KB
/
micro-cron.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
77
78
79
80
#!/bin/bash
IFS_BAK=$IFS;
IFS=$'\n';
file=$1
#ome/santex/data-hub/steam/freq-raw.micro
array=( $(cat $file) );
array2=( $(cat "$file.last") );
A=("one" "two" "three four")
n=0;
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
echo "y"
return 0
fi
}
echo "n"
return 1
}
for item in ${array[@]}
do
#echo $item
array2=( $(cat "$1.last") );
if [ $(contains "${array2[@]}" "$item") == "n" ]; then
echo "contains not $item"
d=$(uptime | tr " " "\n" | egrep "^([1-9]).*.[0-9]" | egrep -v ":" | tr "," "+" | tr -d "\n"); d=$(echo $d|bc);d=$(echo $d/3 | bc);
var=$(ps aux | grep -c micro-wiki-2);
echo $d $var
if [ 8 -lt $d ];
then
killall -9 micro-wiki-2;
sleep 50
n=0;
fi
if [ 80 -lt $var ];
then
echo $n;
let n+=1
killall -9 micro-wiki-2;
sleep 120;
echo "wait";
else
micro-wiki-2 $item &
echo $item >> "$1.last"
n=0;
sleep 1;
fi
fi
done;
echo $n;
IFS=$IFS_BAK;