Now the framework of spring and so on can support the release of the war instead of using the jar, so that the server does not have to install containers, convenient. However, you do not have to install the container to write scripts to complete the service start, stop, restart.
The script is as follows:
#!/bin/bash## chkconfig:345 30# Description: ${description}# processname: ${processname}# Source function library.#!/ Bin/shservice_name=${servicename}path_to_jar=${jarfile}pid_path_name=/tmp/${servicename}-pidcase $ in Start) EC Ho "Starting $SERVICE _name ..." if [! -F $PID _path_name]; Then Nohup Java-jar ${javaargs} $PATH _to_jar/tmp 2>>/dev/null >>/dev/null & Echo $! > $PID _path_name echo "$SERVICE _name started ..." Else echo "$SERVICE _name is already Runn ing ... "fi;; Stop) if [-f $PID _path_name]; Then pid=$ (cat $PID _path_name); echo "$SERVICE _name stoping ..." Kill $PID; echo "$SERVICE _name stopped ..." rm $PID _path_name Else echo "$SERVICE _name is not running. ." fi;; restart) If [-f $PID _path_name]; Then pid=$ (cat $PID _path_name); Echo "$SERVICE _name stopping ..."; Kill $PID; echo "$SERVICE _name stopped ..."; RM $PID _path_name echo "$SERVICE _name starting ..." Nohup Java-jar ${javaargs} $PATH _to_jar/tmp 2& gt;>/dev/null >>/dev/null & Echo $! > $PID _path_name echo "$SERVICE _name started ..." Else echo "$SERVICE _name is not running ... "FI;; Esac
Run as a service on Linux on the Java command line