Minecraft – How to make a Minecraft Server exit automatically when it crashes

minecraft-forgeminecraft-java-editionminecraft-java-edition-server

I am setting up a custom modded server and am running into an issue. During all the block id related crashes, the server jar will still be running even though it crashed. I would like it to quit when it crashes, so I can reboot it easier.

Preferably this would be some option I could stick in my startup script which is

\#\!/bin/bash  
cd "$(dirname "$0")"  
exec java -Xmx1G -Xms1G -jar forge.jar nogui

Thanks in advance

Best Answer

The general idea of an auto shutdown/ auto restart script is that the script needs to know when the server crashes. This can often be done by just having the script listen for certain lines of code or perhaps issuing a list command and wait for its response. I however do not know mac/linux scripts and thus cannot help you there. However i can refer you to alternatives.

One such alternative is Multicraft. It is a server wrapper and provides a web admin panel to remotely manage your server. A built in feature would be the auto-restart after crash function. The server wrapper will constantly ping the server and wait for a response and after a set period of inactivity, restart the server. It also recognises common crash console outputs and reboot the server after crash. Another much simplier alternative is McMyAdmin which also contain an auto-restart function.

A note to the above 2 server wrappers. They both have a free version as well as a paid version. If you are running a server for a couple friends the free version will do fine as it allow for 10 and 8 players to join respectively. If you need more than that, then you can look into the paid options.

Links to both of the server wrapper

http://www.multicraft.org/

http://www.mcmyadmin.com/