linux 下启动java jar包 shell

linux 下启动java jar包 shell

 

#!/bin/sh

JAVA_HOME=/usr/local/jdk1.6.0_34/bin/java
JAVA_OPTS="-Xmx256m"
APP_HOME=/home/ap/injavawetrust/batch

cd $APP_HOME
if [ -f BatchClient.pid ]; then
  PID=$(cat BatchClient.pid)
  echo "=========================="
  echo "service is already started"
  echo "service process ID is $PID"
  echo "=========================="
else
  echo "=========================="
  echo "start service ......"
  nohup $JAVA_HOME $JAVA_OPTS -jar batch.jar  >/dev/null 2>&1 &
  sleep 1
  echo "service started....."
  echo $! > BatchClient.pid
  if [ -f BatchClient.pid ]; then
     PID=$(cat BatchClient.pid)
     echo "start service success!"
     echo  "PID is $PID"
  else
    echo "start service fail!"
  fi
  echo "=========================="
fi

posted on 2016-03-30 16:20  木鱼哥  阅读(600)  评论(0编辑  收藏  举报

导航