编写启动脚本startup.sh
#!/bin/bash echo Starting application
nohup java -jar helloword.jar &
编写关闭脚本stop.sh
#!/bin/bash PID=$(ps -ef | grep helloword.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill $PID kill $PID fi
编写重启脚本restart.sh
#!/bin/bash echo Stopping application source ./stop.sh echo Starting application source ./startup.sh
分别授权文件
chmod +x startup.sh
chmod +x stop.sh
chmod +x restart.sh