vi server.sh
#!/bin/sh
#切换到脚本所在的路径
SERVER=$(cd `dirname $0`; pwd)
cd $SERVER
JAR_NAME=`ls *.jar`
start(){
java -Xmx1024m -Xms1024m -jar $SERVER/*.jar >$SERVER/pwc.log &
echo $! > $SERVER/server.pid
echo "=================================SUCCESS============================================"
}
stop(){
echo "stop project..."
kill `cat $SERVER/server.pid`
rm -rf $SERVER/server.pid
echo "stop project end..."
}
restart(){
stop
sleep 2
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "请输入正确的参数"
echo "start :启动"
echo "stop :停止"
echo "restart :重启"
;;
sh server.sh start
sh server.sh stop
sh server.sh? restart
|