linux 腳本文件,後臺運行jar包並輸出日誌

#!/bin/bash
#chkconfig: 345 90 10
#description: Starts and stops the shaungluJava daemon.
########################################################################
# Purpose:      Start shaungluJava manually                           #
########################################################################
. ~/.bash_profile
ISA_BASE_HOME=/isearch/
JAR_LIB="${ISA_BASE_HOME}/shuanglu"
#LOG_BASE="${ISA_BASE_HOME}/shuanglu/log/log.out"
LOG_BASE1="${ISA_BASE_HOME}/shuanglu/log/log-$(date +%Y-%m-%d).out"
export JAR_LIB


#CLASSPATH="${CLASSPATH}":"${JAR_LIB}/solrstart.jar"

#export CLASSPATH

# Set standard commands for invoking Java.
#RUNJAVA=" java -Xms256m -Xmx1024m  -jar /usr/local/solr/solrstart.jar"
RUNJAVA="nohup  java  -jar /isearch/shuanglu/run.war"

# Set language environment

LANG=zh_CN.gb2312
export LANG
LC_ALL=zh_CN.gb2312
export LC_ALL

usage()
{
		echo "Usage: ./shuanglu.sh  start | stop | status"
}
para=$1

start_app()
{
    #echo Use CLASSPATH: "${CLASSPATH}"
		cd $JAR_LIB
    echo Now Loading the java server, please wait some seconds......
    #$RUNJAVA 1>/dev/null 2>&1   &
      $RUNJAVA >> $LOG_BASE 2>&1 &
}

if [ $# != 1 ]; then
	usage
	exit 0
fi

PIDS=`ps -ef |grep "run.war" | grep -v grep | awk '{print $2}'`

if [ $1 = "start" ]; then
        echo ready to start shuangluJava
        if [ "X$PIDS" != "X" ]; then
                echo shuangluJava has been started, the PID = "${PIDS}"
        else
                # Start programe
                start_app
        fi
fi

if [ $1 = "stop" ]; then
     echo read to Kill shuangluJava, PID="${PIDS}"!
     if [ "X$PIDS" != "X" ]; then
            kill -9 $PIDS
           echo shuangluJava has been killed, PID="${PIDS}"!
     else
           echo shuangluJava has not been stop, the stop command do nothing.
     fi
fi

if [ $1 = "status" ]; then
     if [ "X$PIDS" != "X" ]; then            
           echo shuangluJava server is running
     else
           echo shuangluJava server is stopped.
     fi
fi

文件爲run.shjava

相關文章
相關標籤/搜索