Solved

Keep java session alive.

Posted on 2010-09-22
5
523 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 167 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 167 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 166 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now