restart.sh
#!/bin/bash
# 若存在新版本jar包
if [ -f /tmp/jobs/jobs-encry-0.0.1-SNAPSHOT.jar ]; then
mv -f /tmp/jobs/ /application/springboot/jobs/
fi
# 编译xjar脚本
/usr/local/go/bin/go build /application/springboot/jobs/xjar.go
ps -ef|grep "java -jar /application/springboot/jobs/jobs-encry-0.0.1-SNAPSHOT.jar --spring.profiles.active=pro -Djava.io.tmpdir=/application/springcloud/tmp"|grep -v grep|awk '{print "kill -9 " $2}'|sh
logfile=`date +%Y%m%d%H%M%S`
# 备份日志
mv /application/springboot/logs/jobs.log /application/springboot/logs/jobs_$logfile.sql
# xjar启动应用
nohup /application/springboot/xjar /application/jdk1.8.0_161/bin/java -jar /application/springboot/jobs/jobs-encry-0.0.1-SNAPSHOT.jar --spring.profiles.active=pro -Djava.io.tmpdir=/application/springcloud/tmp >> /application/springboot/logs/jobs.log 2>&1 &
本文介绍了一个使用bash编写的脚本,用于检测新版本jar包、更新应用、杀死旧进程、备份日志并启动新版本的SpringBoot应用,确保无缝升级和日志管理。
1243

被折叠的 条评论
为什么被折叠?



