#!/bin/sh
#
# Appctrl This shell script takes care of starting and stopping
# the VccpDataServer (vccpdsctrl).
#
##########
# jar包存放的位置
prog_path="/usr/local/app/admin"
# jar包名称
prog_name="admin-1.1.0"
exec="JAVA -Xms1024m -Xmx1024m -jar $prog_path""/""$prog_name"".jar"
#查看进程号
prog_pid=`ps -ef | grep $prog_name | grep -v grep | cut -c 10- | cut -c -5|sed 's/ //g'`
prog_time=`date --date='0 days ago' "+%Y/%m/%d %H:%M:%S"`
# get_pid
get_pid(){
prog_pid=`ps -ef | grep $prog_name | grep -v grep | cut -c 10- | cut -c -5|sed 's/ //g'`
echo $prog_pid
}
start(){
prog_pid=$(get_pid);
if [ -n "$prog_pid" ]; then
echo ${prog_time} "$prog_name (pid:$prog_pid) ,and it's running."
return 1
fi
echo ${prog_time} "$prog_name Starting ..."
#export JAVA_HOME=/home/javahome
#export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
#export PATH=$PATH:$JAVA_HOME/bin
echo $exec
nohup $exec >/dev/null 2>&1 &
sleep 10
prog_pid=$(get_pid);
if [ -z "$prog_pid" ]; then
echo ${prog_time} "Start $prog_name is fAIled."
return 2
fi
echo ${prog_time} "$prog_name (pid:$prog_pid) is running."
echo ${prog_time} "Start $prog_name is ok."
return 0
}
stop(){
echo ${prog_time} "$prog_name Stoping..."
prog_pid=$(get_pid);
if [ -n "$prog_pid" ]; then
echo ${prog_time} "Found $prog_name (pid:$prog_pid)"
kill -9 $prog_pid
fi
sleep 3
prog_pid=$(get_pid);
if [ -n "$prog_pid" ]; then
echo ${prog_time} "Stop $prog_name is failed."
return 1
fi
echo ${prog_time} "Stop $prog_name is ok."
return 0
}
status(){
prog_pid=$(get_pid);
if [ -n "$prog_pid" ]; then
echo ${prog_time} "$prog_name (pid:$prog_pid) is running..."
return 0
fi
echo ${prog_time} "$prog_name is stoped."
return 1
}
restart(){
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?
声明:本站部分内容及图片来自互联网,转载是出于传递更多信息之目的,内容观点仅代表作者本人,不构成投资建议。投资者据此操作,风险自担。如有任何标注错误或版权侵犯请与我们联系,我们将及时更正、删除。