#!/bin/bash
# 运行命令 # nohup java -jar ruoyi-admin.jar > ./nohup.out &
# 打包命令 # mvn package -P druid
DATE=`date "+%Y%m%d%H%M%S"`
source /etc/profile
echo “========== 停止包 ruoyi-admin.jar ==========”
PID=`sudo ps -ef |grep "ruoyi-admin.jar" | grep -v grep | awk '{print $2}'`
if [ -z $PID ]
then
echo "jar 没有在运行 ...运行新的jar包"
else
echo "kill $PID"
sudo kill -9 $PID
fi
#
sleep 6
echo "========== 发布新包 ruoyi-admin.jar =========="
cd /home/jump_guest
mkdir -p /data/jarRun/bak
mv /data/jarRun/ruoyi-admin.jar /data/jarRun/bak/ruoyi-admin.jar.$DATE
mv ruoyi-admin.jar /data/jarRun/ruoyi-admin.jar
chown root.root /data/jarRun/ruoyi-admin.jar
sudo find /data/jarRun/bak/ -type f -mtime +30 -exec rm -f {} \;
cd /data/jarRun
nohup java -jar ruoyi-admin.jar > ruoyi.log &