#!/bin/bash USERSERVER="root@212.8.234.87" PROCESS_NAME="java -jar ng-tracker" PROCESS_RUNNING=`ssh -oStrictHostKeyChecking=no $USERSERVER "pgrep -f '$PROCESS_NAME' > /dev/null"` if $PROCESS_RUNNING then ssh $USERSERVER "pkill -f '$PROCESS_NAME'" else echo "not running" fi ./gradlew assemble ssh $USERSERVER "cd /tmp && rm -rf ng-tracker*.jar && echo `date` 'killed' >> log_ng" scp build/libs/ng-tracker-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/ng-tracker-0.1.0-SNAPSHOT.jar ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_144/bin/java -jar ng-tracker-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 >> /home/user/logfile_ng" & sleep 10 echo "is deployed"