启动脚本 #!/bin/bash nohup java -jar XXX.jar > nohup.out 2>&1 & 关闭脚本 PID=$(ps -ef | grep XXX.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill $PID kill -9 $PID fi