Browse Source

调整日志

jiantao 4 years ago
parent
commit
7dab99ad6e
5 changed files with 85 additions and 0 deletions
  1. 21 0
      tools/check_all.sh
  2. 8 0
      tools/p.sh
  3. 24 0
      tools/restart.sh
  4. 14 0
      tools/start.sh
  5. 18 0
      tools/stop.sh

+ 21 - 0
tools/check_all.sh

@@ -0,0 +1,21 @@
1
+#! /bin/sh
2
+PATH=/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/root/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/lib/mit/bin:/usr/lib/mit/sbin
3
+
4
+APP=miads
5
+
6
+cd /data2/app/$APP
7
+
8
+PROCESS=`pwd | xargs -i basename {}`
9
+
10
+#for process number check and alert send
11
+processnum=`/bin/ps -ef | grep "\./${PROCESS}" | grep -v grep  |/usr/bin/wc -l`
12
+if [ $processnum -lt 1 ]
13
+then
14
+    echo "${PROCESS} processnum is $processnum less than 1, please check"
15
+    cd /data2/app/${PROCESS}/tools/
16
+    ./start.sh
17
+else
18
+    echo $processnum
19
+fi
20
+
21
+echo "Done."

+ 8 - 0
tools/p.sh

@@ -0,0 +1,8 @@
1
+#!/bin/sh
2
+
3
+cd ../
4
+
5
+PROCESS=`pwd | xargs -i basename {}`
6
+ps auxf  | grep "\./${PROCESS}" | grep -v grep | awk '{printf "%s\n", $0;}'
7
+
8
+exit 0

+ 24 - 0
tools/restart.sh

@@ -0,0 +1,24 @@
1
+#!/bin/sh
2
+echo "begin restart..."
3
+
4
+cd ../
5
+
6
+PROCESS=`pwd | xargs -i basename {}`
7
+COUNT=`ps -ef|grep "\./$PROCESS"|grep -v grep|wc -l`
8
+
9
+if [ $COUNT -lt 1 ]; then
10
+    echo "process $PROCESS not exist!"
11
+fi
12
+
13
+PID=`ps -ef | grep "$PROCESS" | grep -v grep | grep -v awk | awk '{print $2}'`
14
+
15
+echo "kill -HUP ${PID}"
16
+kill -HUP ${PID}
17
+
18
+if [ $? != "0" ]; then
19
+    echo "Restart $PROCESS Failed."
20
+    exit 1
21
+else
22
+    echo "Restart $PROCESS OK."
23
+    exit 0
24
+fi

+ 14 - 0
tools/start.sh

@@ -0,0 +1,14 @@
1
+#!/bin/sh
2
+
3
+cd ../
4
+
5
+PROCESS=`pwd | xargs -i basename {}`
6
+COUNT=`ps auxf  | grep "\./${PROCESS}" | grep -v grep | awk '{printf "%s\n", $0;}' | wc -l`
7
+
8
+if [ $COUNT -lt 1 ]; then
9
+    echo "[`date +'%Y-%m-%d %T'`] process ${PROCESS} number:$COUNT, fork it!"
10
+    cd bin; 
11
+    nohup ./$PROCESS &
12
+else
13
+    echo "[`date +'%Y-%m-%d %T'`] process ${PROCESS} number is normal:$COUNT"
14
+fi

+ 18 - 0
tools/stop.sh

@@ -0,0 +1,18 @@
1
+#!/bin/sh
2
+echo "Stopping service..."
3
+
4
+cd ../
5
+
6
+PROCESS=`pwd | xargs -i basename {}`
7
+
8
+PID=`ps -ef | grep "\./$PROCESS" | grep -v grep | awk '{print $2}'`
9
+
10
+kill -TERM $PID
11
+
12
+if [ $? != "0" ]; then
13
+    echo "Can't stop."
14
+    exit 1
15
+else
16
+    echo "Service stoped."
17
+    exit 0
18
+fi