标签:linux
一、start.sh
#!/bin/bash
cd `dirname $0`#echo "STDOUT: $STDOUT_FILE"
二、stop.sh
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/conf
SERVER_NAME=`sed ‘/server.name/!d;s/.*=//‘ conf/server.properties | tr -d ‘\r‘`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk ‘{print $2}‘`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
if [ "$1" != "skip" ]; then
$BIN_DIR/dump.sh
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
三、restart.sh
#!/bin/bash
cd `dirname $0`
./stop.sh
./start.sh
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:linux
原文地址:http://blog.csdn.net/dandan2zhuzhu/article/details/46924353