liunx中jar包启动脚本

【liunx中jar包启动脚本】#!/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_pidget_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 1fiecho ${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/binecho $execnohup $exec >/dev/null 2>&1 &sleep 10prog_pid=$(get_pid);if [ -z "$prog_pid" ]; then echo ${prog_time} "Start $prog_name is failed." return 2fiecho ${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_pidfisleep 3prog_pid=$(get_pid);if [ -n "$prog_pid" ]; thenecho ${prog_time} "Stop $prog_name is failed." return 1fiecho ${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 0fiecho ${prog_time} "$prog_name is stoped."return 1}restart(){stopstart}# See how we were called.case "$1" instart)start;;stop)stop;;status)status;;restart)restart;;*)echo $"Usage: $0 {start|stop|status|restart}"exit 2esacexit $?



    推荐阅读