

Then we can use screen to connect to the the Minecraft console screen -r minecraft-server, now we can type a command for the server to stop either stop or restart, these can also be used in-game in the same way (remember to prepend the / when in-game, the console always does this for you). Now we can test this works, in case the service has already been started, we can create a new process using systemctl restart minecraft even if there wasn't a process for this service, it will create a new one.

REPETIER SERVER INIT.D SCRIPT INSTALL
The following will assume one has completed the install steps for Ahtenus' init script for Minecraft/Bukkit servers (this also works perfectly fine for my Spigot server). This is probably not the best resource to use since it doesn't tell you if the particular option should be placed under, or, but nevertheless, it tells you about the key options needed.įollow along for users with a similar issue With a quick read around I was able to find some nice information on systemd unit files.

Thanks to comment, I now have a solution! /etc/inittab doesn't exist on Ubuntu 16.04, but /etc/systemd does which means the solution is a bit different than what it would have been initially. This allows me to start, stop, restart the Minecraft server along with various other commands to control the Minecraft server. Looking at my zzz.log file I can see the problem lays around the exec /etc/init.d/minecraft start command, this line is never successfully executed when Minecraft executes the restart.sh script.

When in-game if I type /restart the Minecraft server shuts down like its supposed to, but never re-launches again. restart.sh the server starts up perfectly fine.
REPETIER SERVER INIT.D SCRIPT OFFLINE
Now, if the Minecraft server is offline and I execute. Since I do not know how the script is invoked, I assumed this could be a child process of the Minecraft server and thus if the Minecraft server process dies, the script will too, having it this way should ensure the command is run. Sleep(5) as it suggests will make the script pause for 5 seconds, this is just to ensure Minecraft has had enough time to shutdown.Įxec will make the following command /etc/init.d/minecraft start run in a different process. Set -x is also another part to help me figure what's going on, this will output each line that is executed into zzz.log because the above lines redirect the output to there. The first two lines will redirect standardout and standarderror (as Linux fluent users will already know) into the zzz.log file, this is just so I can capture the output to help me figure what's going on. I'm attempting to make a restart script for my Minecraft server so my friends can use the /restart command in-game because they don't have SSH access to my server to restart Minecraft.Ĭurrently my restart.sh script contains exec > zzz.log
