#!/bin/bash
file="/opt/wechat/wechat-0.0.1-SNAPSHOT.jar"
new_file="/opt/wechat/wechat.jar"
log="/opt/wechat/wechat.log"
PID=$(ps -ef | grep wechat.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo Application is already stopped
else
echo kill $PID
kill $PID
fi
if [ -f "$file" ]
then
rm -rf $new_file
mv $file $new_file
fi
nohup java -server -jar -Xms512m -Xmx512m $new_file --server.port=8080 --spring.datasource.url=jdbc:postgresql://10.1.1.8:5432/wechat --spring.datasource.username=postgres --spring.datasource.password=oracle >> $log &
根据需要去修改file、new_file、log的路径设置。并且修改grep 后面对应的名称,最后一行根据需求修改相关配置信息