Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Keep java session alive.

Posted on 2010-09-22
5
Medium Priority
?
563 Views
Last Modified: 2013-11-23
Hello experts,

as a hobby I'm trying to run a minecraft server (minecraft.net)

The server runs great but if I close the console the server stops.

The startup command is: java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

I'm running ubuntu 10.04

how can I keep it running with the console closed?
0
Comment
Question by:kinetik20
5 Comments
 
LVL 7

Accepted Solution

by:
ziceva earned 668 total points
ID: 33740418
Two solutions:

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui &
(add an & at the end)

OR

Install screen end run the server inside
0
 
LVL 4

Author Comment

by:kinetik20
ID: 33740445
Ziceva,

Thanks for the fast reply would I just sudo apt-get install screen ?
0
 
LVL 35

Assisted Solution

by:torimar
torimar earned 668 total points
ID: 33741204
On many servers, like Debian, "Screen" is installed as part of the default distribution. I'd expect it to be as such on Ubuntu as well, but on the other hand, running the apt-get command will not do any harm.

Once installed, screen will take a time to get used to. It basically creates virtual terminals that will continue to run when the user has logged out. The tricky bit is to navigate those virtual terminals from the real terminal.

Try to start your server with a string like this:

screen -A -m -d -S mcraft java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

"mcraft" is a random name I chose to identify the screen, you may choose any identifier you like (and remember).
This command creates a virtual terminal called "mcraft", exits this terminal and lets it run in the background. Log out to see if it works.
To re-attach to the terminal that runs the server, use:
screen -r mcraft
This takes you to all the console output your game server might have generated. To leave it, hit:
CTRL+a d

Once inside your virtual terminal, you may want to be able to check all console output, past the usual number of lines, in case there has been a malfunction etc. Type:
CTRL+a ESC
Then scroll up and down with the arrow keys.

For more commands, like see 'man screen' or check here: http://aperiodic.net/screen/quick_reference
0
 
LVL 26

Assisted Solution

by:jar3817
jar3817 earned 664 total points
ID: 33743429
Or just use nohup... the process will go into the background and you can logout without it closing.

# nohup java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
0
 
LVL 4

Author Closing Comment

by:kinetik20
ID: 33746865
Thanks so much everyone for your help!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question