How do I keep my server running without having SSH open on my computer?

Discussion in 'Bukkit Help' started by BigCoots, Nov 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    BigCoots

    I have a VPS to host my new server and I start it by connecting to the VPS via SSH with Putty. I noticed last night though that if I close out of SSH on my laptop, the server goes down no matter what. I'm sure there's a way to keep the server running without SSH open on my laptop, otherwise people wouldn't buy a VPS since they would have to keep their computers on 24/7 anyway. My question is, how do I do this? I did some research and found a couple of articles saying something about screen, but it confused me.

    Can anyone help?
     
  2. Run the server in a screen session (assuming u are using linux):
    Code:
    screen -AmdS screenname java -jar craftbukkit.jar
    
    Of course you can put any extra arguments behind the java and name the screen as you like.
    To detach the screen so that you can execute normal linux commands in your base shell again. Press:
    Code:
    CTRL+a and then d
    
    To resume the screen type:
    Code:
    screen -r screenname
    
    Remember that linux is case sensetive.
     
    Thury and fernferret like this.
  3. Offline

    BigCoots

    So I do that before or after I start the server? Because after I start the server the terminal is stuck like

    >

    And only accepts bukkit commands I think.
     
  4. Offline

    ShaDooM

    You do that before you start the server.
     
  5. Oh and I forgot. After you started the server like this press

    CTRL+A then D

    This will detach the window and you are back in your normal Shell.
     
    fernferret likes this.
  6. You could also start the screen session with a name:
    Code:
    $ screen -S minECraft
    Then run your startup (this is just a little shell script that I wrote):
    Code:
    $ ./run_minecraft.sh
    Then feel free to close putty whenever. When you want to resume, if you don't remember the name, you can do:
    Code:
    $ screen -ls
    There is a screen on:
    	97768.minECraft	(Detached)
    1 Socket in /var/folders/_w/63586kts5kzdbb0xtq0r7r3r0000gn/T/.screen.
    
    Then, as @silthus said, resume with
    Code:
    $ screen -r minECraft
    or
    Code:
    $ screen -r 97768
    NOTES: I used "minECraft" as the name to show how it carries through the steps.
    NOTES: For completeness, here is that shell script if anyone's interested, but they're seriously all over:
    Code:
     #!/bin/bash
    
    java -Xincgc -Xmx2G -jar craftbukkit.jar
    NOTES: For super-completeness, here is the script that lets you update to the latest CB (you can run "./update.sh" to go to a stable build, or "./update.sh dev" to go to a dev build)
    Code:
    #!/bin/bash
    
    ver="stable"
    if [ -z $1 ] ; then
        echo "Updating to latest STABLE build."
    else
        ver="dev"
        echo "Updating to latest DEV build."
    fi
    
    
    if [ ! -d incoming ] ; then
        mkdir incoming
    else
        rm -rf incoming
        mkdir incoming
    fi
    cd incoming
    if [[ $ver == "dev" ]] ; then
        wget -N http://ci.bukkit.org/job/dev-CraftBukkit/lastSuccessfulBuild/artifact/*zip*/archive.zip
    else
        wget -N http://ci.bukkit.org/job/dev-CraftBukkit/Recommended/artifact/*zip*/archive.zip
    fi
    unzip archive.zip
    cd archive/target/
    mv *.jar ../../../craftbukkit.jar
    Wow... this post got a lot longer than I'd originally set it out to be...
     
Thread Status:
Not open for further replies.

Share This Page