#!/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/AAA.jar $my_back_dir/AAA.jar_$RANDOM
pidList=$(ps aux | grep /java/webapps/AAA.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/AAA.jar $APP_PATH
echo "scp file end"
echo "start app"
nohup java -jar /java/webapps/AAA.jar --spring.profiles.active=test &
nohup java -jar /java/webapps/AAA.jar --spring.profiles.active=publish &
echo "start app end"