参考资料

重启

sh spring-boot.sh java_jar_name

 

#!/bin/bash
jar_name=$1
if [ "$jar_name" = "" ];
then
    echo -e "\033[0;31m 未输入应用名 \033[0m"
    exit 1
fi
pid=$(ps x | grep java| grep $jar_name | grep -v grep | awk '{print $1}')
echo $pid
if [ "$pid" != "" ];
then
    echo "kill${pid}"
    kill -9 $pid;
fi
# 休眠10秒,保证程序被彻底关闭
sleep 10s;
file_path_name="/web/xxfbpt/${jar_name}.jar";
echo $file_path_name;
if [ ! -e "$file_path_name" ]; then
  echo "文件不存在";
  exit 0;
fi
nohup java -jar $file_path_name > /home/q/www/nohup.log 2>&1 &
echo "启动项目"