Linux startup script to back up what jar
#! / bin / bash # here can be replaced with your own implementation of the program, other code without changing APP_NAME = Health-Card-Web-1.0 .jar cd `dirname $ 0 ` # instructions, to enter the argument usage () { echo "Usage: SH execute the script .sh [Start | STOP | restart | Status]" Exit 1 } # check program is running is_exist () { pid = `PS -ef | grep $ APP_NAME | grep -v grep | awk 'Print $ {2}' ` # returns 1 if there is, exists returns 0 IF [the -Z" PID $ {} " ]; the then return 1 the else return 0 Fi } # startup method start () { is_exist IF [ $? -eq "0" ]; then echo "${APP_NAME} is already running. pid=${pid} ." else nohup java -jar $APP_NAME > /dev/null 2>&1 & echo "${APP_NAME} is start success" #tail -f fileserver-web.out fi } #停止方法 stop(){ is_exist if [ $? -eq "0" ]; then kill -9 $pid echo "${APP_NAME} is stoped" else echo "${APP_NAME} is not running" is_exist Status () { # output running state } Fi IF [? $ -eq "0" ]; the then echo . "$ {APP_NAME} IS running IS the Pid PID $ {}" the else echo . "$ {IS} APP_NAME the NOT running" Fi } # restart the restart () { STOP Start } # the input parameter, performing the corresponding selected method is performed without input instructions Case "$. 1" in "Start" ) Start ;; "STOP" ) STOP ;; "Status" ) Status ;; "the restart" ) the restart ;; * ) Usage ;; esac