shell指令碼示例,start stop restart
阿新 • • 發佈:2019-02-07
PID_FILE=pid/malformedword.pid CLASS_PATH=package/lib MAIN_CLASS=com.youku.netty.HttpServer echo "start? stop? restart? " read key case "$key" in start) if [ ! -f $PID_FILE ]; then echo "server starting ..." nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 & echo $! > $PID_FILE echo "server started" else echo "server is already started" fi ;; stop) if [ -f $PID_FILE ]; then PID=$(cat $PID_FILE); echo "server stoping ..." kill -9 $PID; rm $PID_FILE echo "server stoped" else echo "server is already stoped" fi ;; restart) if [ -f $PID_FILE ]; then PID=$(cat $PID_FILE); echo "server stoping ..." kill -9 $PID; rm $PID_FILE echo "server stoped" echo "restart ..." echo "server starting ..." nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 & echo $! > $PID_FILE echo "server started" else echo "server starting ..." nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 & echo $! > $PID_FILE echo "server started" fi ;; esac