[TUT]Start your server automatically after /stop

Aug 26, 2017
[TUT]Start your server automatically after /stop
  • ( And how should this work with screen? )
    In this theread I will show you, how you can easilly start your server automatically, after you execute the command /stop (console & in-game).


    Useful for Minigame-Servers (like BedWars, 1vs1 etc.)

    IMPORTANT: This script works only on Linux-based systems.

    You need to connect via SSH to your Server.
    (I recommend Putty. Download: http://goo.gl/Pp5Pnw)


    First, we need to create a file which will be the script:
    Code (Text):
    nano start.sh
    If you don't have nano, install it with the following command:
    Code (Text):
    sudo apt-get install nano -y
    Then run the first command again.

    Now, it should look like this:
    [​IMG]

    Now, you need to insert the following text:
    Code (Text):
    #!/bin/sh
    while true
    do
    java -jar YOURFILE.jar
    sleep 5
    done
     
    Be sure to replace "YOURFILE" with the filename of your start jar (like Spigot.jar, BungeeCord.jar, Bukkit.jar)

    Now, it should look like this:
    [​IMG]

    Be sure to save the file by pressing CTRL+X then Y then ENTER.

    The script is saved now and is ready to run.
    Be sure the file ist executable by typing:
    Code (Text):
    chmod 777 -R start.sh

    Now, when you run the script, the server will start normally and the script tests, if the process is running.
    If you stop the server, the scrip detects that the process is stopped and will start the server again.

    I hope I could help you :)
  • Loading...
  • Loading...