Centos tmux restart script

Discussion in 'Systems Administration' started by KaareZ, Jun 7, 2014.

  1. Don't mix those two scrips. Just use the one I sent you.

    You have a syntax error in your script, but this is a bad way of achieving this.
  2. The one you sent wont create any sessions or so. I run multiple servers on the dedi
  3. Start that script INSIDE TMUX.
    When you use /stop, the script will loop. Fiddling with sessions is not neccesary.
  4. So I start a tmux session. And inside that I run start.sh?
  5. Okay. Heres my exact code.
    Code (Text):
    while true
        java -Xmx4G -Xms4G -jar ../../jars/spigot.jar
            echo "You have three seconds to do 'Ctrl+C' to stop the server. The server will auto restart in three seconds."
        sleep 3
    I still get the error about "done"
  6. Still getting an error.
    Code (Text):
    start.sh: line 6: syntax error near unexpected token `done'
    start.sh: line 6: `done'
  7. How are you launching the script? Are you using /bin/sh?
  8. I take the text you sent and save it as start.sh Then in ssh I do "bash start.sh"
  9. Run these two commands:

    chmod +x start.sh

    Then use ./start.sh to start the server.
  10. still getting that message about the token.
  11. vemacs


    Has anybody heard of the manual? Jesus.

    New Window: tmux new-window -n spigot
    Start: tmux send-keys -t spigot cd spigot; ./start.sh C-m
    Stop: tmux send-keys -t spigot stop C-m

    Also, why start the server in a while loop when you can just use the native /restart command with a script?

    Just stick the start command and chmod +x. Done.

    I hate to be rude, but 5 minutes of Googling, anyone?
  12. vemacs


    Don't sleep. Just:

    Code (Text):
    tmux send-keys -t <your window or mc-skyblock:0> ./start.sh C-m
    The script is executed after server shutdown: https://github.com/SpigotMC/Spigot-...ain/java/org/spigotmc/RestartCommand.java#L80

    You'd have to use a server wrapper (Mark2, Multicraft, whatever) and use their commands in order to display the message before restart.
  13. vemacs


    Well, maybe because the bash executable probably isn't in the path Spigot executes? :p

    Use sh if you don't need bash features. Also chmod +x.
  14. The script was in the minecraft servers root. (With plugins, world etc)
  15. vemacs



    Unix PATH. Use #!/bin/sh. Do a cat or something if you don't believe it's being run.
  16. If my minecraft servers folder is /home/servers/hungergames1 Where should I then place the script?
  17. vemacs


    You place it right there?
  18. I place start.sh in the same directory as my server. Is that wrong?