Solved

Keep java session alive.

Posted on 2010-09-22
5
548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video teaches viewers about errors in exception handling.
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.

724 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