Solved

Keep java session alive.

Posted on 2010-09-22
5
534 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example 11 40
Unhandled exception type Exception 18 28
000webhost.com default error log 1 25
Quickest way to query Windows Event ID from a Linux Device 3 26
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

806 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