赞
踩
#!/bin/sh
APP_NAME=sms-service
JAR_PATH='/home/ap/t_jar'
JAR_NAME=*.jar
LOG_PATH='/home/ap/t_jar/okdata/logs/session'
usage() {
echo "Usage: sh sms.sh [start|stop|restart|status]"
exit 1
}
is_exist(){
pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
if [ -z "${pid}" ];
then
return 1
else
return 0
fi
}
start(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> $APP_NAME is already running PID=${pid} <<<"
else
nohup java -Xms128m -Xmx512m -jar $JAR_PATH/$JAR_NAME --spring.profiles.active=212 >> null 2>&1 &
echo ">>> start $APP_NAME successed PID=$! <<<"
fi
}
stop(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> PID = $pid begin kill -9 $pid <<<"
kill -9 $pid
sleep 2
echo ">>> $APP_NAME process stopped <<<"
else
echo ">>> $APP_NAME is not running <<<"
fi
}
status(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> $APP_NAME is running PID is ${pid} <<<"
else
echo ">>> $APP_NAME is not running <<<"
fi
}
restart(){
stop
start
}
printLog()
{
tail -f /home/ap/zhfc/t_jar/okdata/logs/session/session_debug.log
}
case "$1" in
"start")
start
printLog
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
printLog
;;
*)
usage
;;
esac
exit 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。