-
Notifications
You must be signed in to change notification settings - Fork 10
/
cmd.sh
53 lines (43 loc) · 1.03 KB
/
cmd.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
#!/bin/bash
# export scripts=$PWD
# cd $scripts && bash cmd.sh stop && svn update && cd $scripts && cd $scripts && bash cmd.sh start
# 日志保存路径
LOG_DIR=/bgi/logs/open-falcon
mkdir -p $LOG_DIR
# 采集脚本列表
scripts=(du.sh proc.sh)
function start(){
arr=$@
if [ "$arr" == "" ];then
arr=${scripts[@]}
fi
for sh in ${arr[@]};do
echo start $sh
nohup bash $sh $LOG_DIR >${LOG_DIR}/$sh.out 2>&1 &
sleep 1
done
}
function stop(){
arr=$@
if [ "$arr" == "" ];then
arr=${scripts[@]}
fi
# echo ${arr[@]}
for sh in ${arr[@]};do
pids=$(ps -aux|grep -v grep|grep -v cmd.sh|grep "$sh"|awk '{print $2}'|tr -s '\n' ' ')
echo stop $sh $pids
kill -9 $pids
done
}
function status(){
arr=$@
if [ "$arr" == "" ];then
arr=${scripts[@]}
fi
# echo ${arr[@]}
for sh in ${arr[@]};do
pids=$(ps -aux|grep -v grep|grep -v cmd.sh|grep "$sh"|awk '{print $2}'|tr -s '\n' ' ')
echo status $sh $pids
done
}
$@