脚本发布程序 jar包重启程序-验证通过

#!/bin/bash

date_str=`date +%Y%m%d`
dir=/java/backup
my_back_dir="$dir/$date_str"
export APP_PATH=/java/webapps


echo "[$(date +'%F %T')] >>> BACK UP APP."
if [ ! -d "$my_back_dir" ]; then
echo "Create Dir"
mkdir $my_back_dir
else
echo "Dir Exists"
fi

scp $APP_PATH/jinan-hospital-api-2.1.3.RELEASE.jar $my_back_dir/jinan-hospital-api-2.1.3.RELEASE.jar_$RANDOM

pidList=$(ps aux | grep /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar | grep -v grep | awk '{print $2}')
for pid in $pidList;do
kill -9 $pid
echo "[$(date +'%F %T')] >>> kill the precess [$pid] successfully."
done

echo "scp file start"
scp /java/publish_dir/jinan-hospital-api-2.1.3.RELEASE.jar $APP_PATH
echo "scp file end"

echo "start app"
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=test &
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=publish &
echo "start app end"

---------------------------------------------------------------------------

-------------jar包重启程序

#!/bin/bash

date_str=`date +%F%T`
export APP_PATH=/java/webapps
echo $date_str restart app >> /java/task_restart.log
echo "jinan-hospital-api-2.1.3.RELEASE.jar start" >> /java/task_restart.log

cd /java/webapps
pidList=$(ps aux | grep /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar | grep -v grep | awk '{print $2}')
for pid in $pidList;do
kill -9 $pid
echo "[$(date +'%F %T')] >>> kill the precess [$pid] successfully." >> /java/task_restart.log
done


echo "start app" >> /java/task_restart.log
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=test &
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=publish &
echo "start app end" >> /java/task_restart.log

echo "jinan-hospital-api-2.1.3.RELEASE.jar end" >> /java/task_restart.log

------------------------------------------------------------------------------------------------------------

-------jar包备份发布脚本验证通过

#!/bin/bash

date_str=`date +%Y%m%d`
dir=/java/backup
my_back_dir="$dir/$date_str"
export APP_PATH=/java/webapps


echo "[$(date +'%F %T')] >>> BACK UP APP."
if [ ! -d "$my_back_dir" ]; then
echo "Create Dir"
mkdir $my_back_dir
else
echo "Dir Exists"
fi

scp $APP_PATH/jinan-hospital-api-2.1.3.RELEASE.jar $my_back_dir/jinan-hospital-api-2.1.3.RELEASE.jar_$RANDOM

pidList=$(ps aux | grep /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar | grep -v grep | awk '{print $2}')
for pid in $pidList;do
kill -9 $pid
echo "[$(date +'%F %T')] >>> kill the precess [$pid] successfully."
done

echo "scp file start"
scp /java/publish_dir/jinan-hospital-api-2.1.3.RELEASE.jar $APP_PATH
echo "scp file end"

echo "start app"
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=test &
nohup java -jar /java/webapps/jinan-hospital-api-2.1.3.RELEASE.jar --spring.profiles.active=publish &
echo "start app end"

posted on 2021-06-15 10:56  四海骄阳  阅读(70)  评论(0编辑  收藏  举报

导航