2020年5月20日 | Leave a comment 问题 解决: #!/bin/bash #./deploy.sh root@a.com b@c.com build() { mvn -verbose mvn -DskipTests=true clean package } upload() { SITE=$1 echo $SITE; scp target/r.jar $SITE:/home/app/temp/ scp -r target/lib/ $SITE:/home/app/temp/ ssh $SITE 'mv /home/app/temp/r.jar /home/app/run/r.jar ' ssh $SITE 'rm -rdf /home/app/run/lib/ && mv /home/app/temp/lib/ /home/app/run/ ' PSAUX=$(ssh $SITE ps aux | grep -i r.jar | grep java | grep -v bash) PID=$(echo $PSAUX | awk 'RS {print $2 }') if [ -n $PID ]; then echo "kill -9 $PID" ssh $SITE "kill -9 $PID" sleep 5 fi echo " start ..." ssh $SITE 'cd /home/app/run && nohup java -jar /home/app/run/r.jar >/home/app/run/app.log 2>&1 & ' } build for i in $@ do upload "$i" done 123456789101112131415161718192021222324252627282930 #!/bin/bash#./deploy.sh root@a.com b@c.com build() { mvn -verbose mvn -DskipTests=true clean package}upload() { SITE=$1 echo $SITE; scp target/r.jar $SITE:/home/app/temp/ scp -r target/lib/ $SITE:/home/app/temp/ ssh $SITE 'mv /home/app/temp/r.jar /home/app/run/r.jar ' ssh $SITE 'rm -rdf /home/app/run/lib/ && mv /home/app/temp/lib/ /home/app/run/ ' PSAUX=$(ssh $SITE ps aux | grep -i r.jar | grep java | grep -v bash) PID=$(echo $PSAUX | awk 'RS {print $2 }') if [ -n $PID ]; then echo "kill -9 $PID" ssh $SITE "kill -9 $PID" sleep 5 fi echo " start ..." ssh $SITE 'cd /home/app/run && nohup java -jar /home/app/run/r.jar >/home/app/run/app.log 2>&1 & '} buildfor i in $@do upload "$i"done 参考: