I would start with this template to run the script, rename SCRIPT_HOME
to the correct path and call this file without any extensions, then run this command in SSH.
chkconfig βadd javaserver
Please note that javaserver
in chkconfig
is how you called the file below (no extensions or it will not work).
#!/bin/bash # # javaserver: Startup script for Any Server Application. # # chkconfig: 35 80 05 # description: Startup script for Any Server Application. SCRIPT_HOME=/var/java_server; export SCRIPT_HOME start() { echo -n "Starting Java Server: " $SCRIPT_HOME/run.sh start sleep 2 echo "done" } stop() { echo -n "Stopping Java Server: " $SCRIPT_HOME/run.sh stop echo "done" } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: javaserver {start|stop|restart}" exit esac
Now here is the script run.sh (this can be used instead of the template, but itβs easier for me to make the script template a small and immutable link to my main script, so I will never have to touch it again.
Below is the script, one of the very few scripts that, in my opinion, can restart the java program without shutting down all the java programs that you are currently running, it is only intended for the program that it opened in the first place, therefore never would make no mistakes, would never work for me, run as root
without problems.
Runs your program in the background forever (no need to keep SSH open).
This is run.sh
#!/bin/bash
source share