-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctl.monitor.sh
59 lines (55 loc) · 1015 Bytes
/
ctl.monitor.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
#!/bin/bash
SCRIPT_PATH=`pwd`
MONITOR_DAEMON="monitor_process_sdo.sh"
start()
{
PRC_MONITOR=`ps -ef | grep "$MONITOR_DAEMON" | grep -v "grep"`
if [ -z "$PRC_MONITOR" ]
then
chmod +x $SCRIPT_PATH/$MONITOR_DAEMON
sh $SCRIPT_PATH/$MONITOR_DAEMON > /dev/null 2>&1 &
echo "$MONITOR_DAEMON started"
else
echo "$MONITOR_DAEMON is already running"
fi
}
stop()
{
PRC_MONITOR=`ps -ef | grep "$MONITOR_DAEMON" | grep -v "grep"`
if [ -z "$PRC_MONITOR" ]
then
echo "$MONITOR_DAEMON is not running"
else
killall -9 $MONITOR_DAEMON
echo "$MONITOR_DAEMON stop"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
A=`ps -ef | grep "$MONITOR_DAEMON" | grep -v grep | wc -l`
if [ $A == 0 ]
then
echo "$MONITOR_DAEMON is stoped"
else
echo ps -ef | grep $MONITOR_DAEMON
fi
;;
help)
echo "Usage: $0 {start|stop|restart|status|help}"
exit 1
;;
*)
echo "Usage: $0 {start|stop|restart|status|help}"
exit 2
esac