Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法

废话不多说了,先给大家上代码,具体代码如下所示:

#!/bin/bash
cd `dirname 启动jar包:`
CUR_SHELL_DIR=`pwd`
CUR_SHELL_NAME=`basename ${BASH_SOURCE}`
#修改这里jar包名即可
JAR_NAME="xxxxxxxxxxxx.jar" 
JAR_PATH=$CUR_SHELL_DIR/$JAR_NAME
#JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m"
JAVA_MEM_OPTS=""
#SPRING_PROFILES_ACTIV="-Dspring.profiles.active=eureka2"
SPRING_PROFILES_ACTIV=""
LOG_DIR=$CUR_SHELL_DIR/logs
LOG_PATH=$LOG_DIR/${JAR_NAME}.log
echo_help()
{
  echo -e "syntax: sh $CUR_SHELL_NAME start|stop"
}
if [ -z  ];then
  echo_help
  exit 1
fi
if [ ! -d "$LOG_DIR" ];then
  mkdir "$LOG_DIR"
fi
if [ ! -f "$LOG_PATH" ];then
  touch "$LOG_DIR"
fi
if [ "" == "start" ];then
# check server
  PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print }'`
  if [ -n "$PIDS" ]; then
    echo -e "ERROR: The $JAR_NAME already started and the PID is ${PIDS}."
    exit 1
  fi
echo "Starting the $JAR_NAME..."
 
  # start
  nohup java $JAVA_MEM_OPTS -jar $SPRING_PROFILES_ACTIV $JAR_PATH >> $LOG_PATH 2>&1 &
 
  COUNT=0
  while [ $COUNT -lt 1 ]; do
    sleep 1
    COUNT=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print }' | wc -l`
    if [ $COUNT -gt 0 ]; then
      break
    fi
  done
  PIDS=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print }'`
  echo "${JAR_NAME} Started and the PID is ${PIDS}."
  echo "You can check the log file in ${LOG_PATH} for details."
 
elif [ "" == "stop" ];then
 
  PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print }'`
  if [ -z "$PIDS" ]; then
    echo "ERROR:The $JAR_NAME does not started!"
    exit 1
  fi
echo -e "Stopping the $JAR_NAME..."
 
  for PID in $PIDS; do
    kill $PID > /dev/null 2>&1
  done
 
  COUNT=0
  while [ $COUNT -lt 1 ]; do
    sleep 1
    COUNT=1
    for PID in $PIDS ; do
      PID_EXIST=`ps --no-heading -p $PID`
      if [ -n "$PID_EXIST" ]; then
        COUNT=0
        break
      fi
    done
  done
 
  echo -e "${JAR_NAME} Stopped and the PID is ${PIDS}."
else
  echo_help
  exit 1
fi

以上代码只需修改jar包名即可使用

 ./xxxx.sh start

停止 jar包

./xxxx.sh stop

总结

[+++]

以上所述是小编给大家介绍的Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
` CUR_SHELL_DIR=`pwd` CUR_SHELL_NAME=`basename ${BASH_SOURCE}` #修改这里ja" /> ` CUR_SHELL_DIR=`pwd` CUR_SHELL_NAME=`basename ${BASH_SOURCE}` #修改这里ja"> Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法_软件运维_内存溢出

阅读 42

Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法,第1张

Linux 启动停止SpringBoot jar 程序部署Shell 脚本

的方法
废话不多说了,先给大家上代码,具体代码如下所示:


#!/bin/bash
cd `dirname 
启动jar包:

` CUR_SHELL_DIR=`pwd` CUR_SHELL_NAME=`basename ${BASH_SOURCE}` #修改这里jar包名即可 JAR_NAME="xxxxxxxxxxxx.jar" JAR_PATH=$CUR_SHELL_DIR/$JAR_NAME #JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m" JAVA_MEM_OPTS="" #SPRING_PROFILES_ACTIV="-Dspring.profiles.active=eureka2" SPRING_PROFILES_ACTIV="" LOG_DIR=$CUR_SHELL_DIR/logs LOG_PATH=$LOG_DIR/${JAR_NAME}.log echo_help() { echo -e "syntax: sh $CUR_SHELL_NAME start|stop" } if [ -z ];then echo_help exit 1 fi if [ ! -d "$LOG_DIR" ];then mkdir "$LOG_DIR" fi if [ ! -f "$LOG_PATH" ];then touch "$LOG_DIR" fi if [ "" == "start" ];then # check server PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print }'` if [ -n "$PIDS" ]; then echo -e "ERROR: The $JAR_NAME already started and the PID is ${PIDS}." exit 1 fi echo "Starting the $JAR_NAME..." # start nohup java $JAVA_MEM_OPTS -jar $SPRING_PROFILES_ACTIV $JAR_PATH >> $LOG_PATH 2>&1 & COUNT=0 while [ $COUNT -lt 1 ]; do sleep 1 COUNT=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print }' | wc -l` if [ $COUNT -gt 0 ]; then break fi done PIDS=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print }'` echo "${JAR_NAME} Started and the PID is ${PIDS}." echo "You can check the log file in ${LOG_PATH} for details." elif [ "" == "stop" ];then PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print }'` if [ -z "$PIDS" ]; then echo "ERROR:The $JAR_NAME does not started!" exit 1 fi echo -e "Stopping the $JAR_NAME..." for PID in $PIDS; do kill $PID > /dev/null 2>&1 done COUNT=0 while [ $COUNT -lt 1 ]; do sleep 1 COUNT=1 for PID in $PIDS ; do PID_EXIST=`ps --no-heading -p $PID` if [ -n "$PID_EXIST" ]; then COUNT=0 break fi done done echo -e "${JAR_NAME} Stopped and the PID is ${PIDS}." else echo_help exit 1 fi

以上代码只需修改jar包名即可使用

 ./xxxx.sh start

停止 jar包

./xxxx.sh stop


总结


以上所述是小编给大家介绍的Linux 启动停止SpringBoot jar 程序部署Shell 脚本的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

欢迎分享,转载请注明来源:

内存溢出

原文地址:

http://outofmemory.cn/yw/902520.html
jar
(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
code code 管理员组
Linux下使用killall命令终止进程的8大用法实例详解
上一篇
2022-05-15
Linux中把用户添加到组的4个方法总结
2022-05-15

发表评论
请登录后评论... 登录
提交

    评论列表(0条)
保存
{label} {label} `CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里ja', author : 'code', cat_name : '软件运维', time_y_m : '2022年05月', time_d : '15', site_motto : '内存溢出' }; {script} {script}