项目里面经常用到的启动jar包的shell脚本,
如果有错误或者优化请补充
PID=$(ps -elf | grep que-service-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $4}');
echo '重启前que-service进程号'
echo $PID
kill -9 $PID
wait
git pull
echo '代码更新成功'
wait
echo '开始给项目打包'
mvn clean package -DskipTests
wait
nohup java -jar target/que-service-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev >> nohup.out &
wait
PID=$(ps -elf | grep que-service-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $4}');
echo '重启后que-service 进程号'
echo $PID
wait
tail -f nohup.out
优化版本
Project_Path=/home/BigDataEdu/Que_Bank
jar_file="que-cloud-bank-0.0.1-SNAPSHOT.jar"
cd $Project_Path
echo "当前路径"
pwd
rm -rf target
ls -l
pwd
git reset --hard origin/master
git branch
git pull
git log -n1
mvn clean package -DskipTests
ls -l $Project_Path/target
PID=$(ps -elf | grep $jar_file | grep -v grep | awk '{print $4}');
echo '重启前que-cloud-bank进程号'
echo $PID
kill -9 $PID
cd $Project_Path/target
echo "jar文件路径"
pwd
nohup java -jar $jar_file --spring.profiles.active=dev &
tail -f nohup.out