每次手动编译运行java项目实在是太麻烦了,而且由于服务器上有多个java版本,项目又需要指定使用java8,故写了个脚本来进行编译并重启。需要自定调整项目目录及java、maven的目录

#/bin/bash
cd /home/scuser/java/weapp-push && \
git pull && \
export JAVA_HOME=/usr/local/java/jdk1.8.0_191 && \
/usr/local/maven/apache-maven-3.6.0/bin/mvn -DskipTests clean install && \

if pkill -f weapp-push.jar; then
    nohup /usr/local/java/jdk1.8.0_191/bin/java -jar target/weapp-push.jar > myout.file 2>&1 &
else
    nohup /usr/local/java/jdk1.8.0_191/bin/java -jar target/weapp-push.jar > myout.file 2>&1 &
fi