可放在idea根目录命名为pub.sh
mvn clean install -Dmaven.test.skip=true
CRTDIR=$(pwd)
scp ${CRTDIR}/target/app.jar root@ip:/usr/local/test
sleep 1
ssh -tt root@ip << eeooff
cd /usr/local/test
./start.sh &
exit
eeooff
echo done!
start.sh
#!/usr/bin/env bash
pid= #进程pid
pid=`ps -ef |grep java|grep app |awk '{print $2}'`
echo "PID: $pid"
if [[ -n "$pid" ]];then
kill -9 $pid
else
echo '正在执行'
fi
sleep 2
echo '正在执行'
nohup java -jar app.jar > log.log 2>&1 &
centos提前配置好ssh免密登录,部署的时候 sh pub.sh即可
网友评论