[Linux] Startup script & Screen

Discussion in 'Systems Administration' started by TheOnlyRealTGS, Feb 2, 2015.

  1. TheOnlyRealTGS

    Supporter

    Hi,
    I've started a Spigot server inside a window (inside a screen session), and when I do /restart it shut downs the server (ofc) and starts the server in the background, aka no inside my window.
    How do I make it start inside the window, so I can see the server log etc?

    Startup script:
    Code (Text):
     java -server -Xmx5G -XX:MaxPermSize=128M -jar custom.jar
     
    • Funny Funny x 1
    • Informative Informative x 1
  2. you can do like this:
    Code (Text):

    screen -S "screenname" -U -m -d java -server -Xmx5G -XX:MaxPermSize=128M -jar custom.jar
     
    And that would be in the startup script.
     
  3. Why the doublepost?
    Interesting that both threads got different solutions though.
     
  4. TheOnlyRealTGS

    Supporter

    Okay, but would this ensure it to start in the same window, and not just the same screen?
    At first, I wasn't sure where to post it, then realized that this would be the most appropriate place.
     
  5. Create a separate shell script, lets call it server.sh

    Code (Text):
    #!/bin/bash
    while true; do
        java -server -Xmx5G -XX:MaxPermSize=128M -jar custom.jar
    done;
    And in your server start script:
    Code (Text):
    screen -S Minecraft_Server -d -m sh server.sh
    Explanation:
    You can ditch the /restart command, upon /stop, it will automatically restart.
    Hacky, but will do exactly what you need.
    Flags:
    • -S = screen name
    • -d -m = start screen in detached mode.
     
    • Like Like x 2
  6. TheOnlyRealTGS

    Supporter

    Yeah, the first script did the trick :)
     
    • Like Like x 1
    • Agree Agree x 1