Jar包启动脚本

sh service restart xxx.jar

#!/bin/bash
args='-Duser.timezone=America/Los_Angeles  -Dspring.profiles.active=test'
cmd=$1
app=$2
pid=`ps -ef|grep java|grep $app|awk '{print $2}'`

startup(){
  nohup java -jar $args $app  &
#  nohup java -jar $args $app >> /address/logs/$app-catalina.out  2>&1 &
#  echo "tail -f /address/logs/$app-catalina.out"
}

if [ ! $cmd ]; then
  echo "Please specify args 'start|restart|stop'"
  exit
fi

if [ $cmd == 'start' ]; then
  if [ ! $pid ]; then
    startup
  else
    echo "$app is running! pid=$pid"
  fi
fi

if [ $cmd == 'restart' ]; then
  if [ $pid ]
    then
      echo "$pid will be killed after 3 seconds!"
      sleep 3
      kill  $pid
  fi
  startup
fi

if [ $cmd == 'stop' ]; then
  if [ $pid ]; then
    echo "$pid will be killed after 3 seconds!"
    sleep 3
    kill  $pid
  fi
  echo "$app is stopped"
fi
文章作者: LibSept24_
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LibSept24_
Linux shell shell
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝