Restarting a crashed server

Discussion in 'Systems Administration' started by Alstroemeria, May 15, 2015.

  1. Hi, I've been poking around with the for our server recently, and found that while it does allow for the use of /restart or /stop to restart the server, I can't seem to find a way to make the server restart when it is crashed.

    For example, if the server freezes and crashes, and it (apparently) tries to reboot the server with, it seems to not be able to, because java is still running, even after the crash. The port is still being used by java, and therefore the server cannot reboot properly. The solution that I believed would work was to put pkill -9 java in the, but it had no effect. Is there a way to make java kill itself when the server crashes, or kill it from the startup script?

    Here is what I am using currently, a, which continually starts the server, and a, which opens the in a screen, and (doesn't work) uses pkill to kill java.
    Code (startsh (Unknown Language)):
    screen -S server -d -m sh
    Code (serversh (Unknown Language)):
     # /bin/sh
    while true
    java -Xmx16G -server -XX:+UseConcMarkSweepGC -jar spigot-*.jar
    echo Its off..sleeping for 5
    sleep 5
    Any help would be greatly appreciated. Thanks!
  2. Try running a kill on the process right before sleep.
  3. When I used that, it constantly ran the pkill command every 5 seconds, killing the server before it could even startup. Is there a way to make it so that it only executes the command when ./ is used? When I try putting it in, it doesn't seem to work.

    Also, I think this is a problem with the ./ not properly being executed on a server crash, as using ./ works fine (not executed by spigot) if the pkill -9 java is in