Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm a Linux n00b, but it's something I'm really trying to learn.

Let's say I log in to my server at home directly and start a process. For the sake of specificity, it's a CraftBukkit Minecraft server. :)

There were some issues and now I want to restart the game server remotely. How can I log in and up that terminal session that is running the server?

I can access the computer through remote desktop. I can set up SSH if necessary.

Thanks!

share|improve this question
    
Shouldn't the title be "Accessing running terminal sessions" ? –  jmbouffard Jul 12 '11 at 18:31
    
I suppose it should. I'm not sure how to edit the title. –  Jesse Jul 12 '11 at 19:13

1 Answer 1

up vote 2 down vote accepted

You cannot log remotely to a terminal that is already running on the machine.

Instead, use ssh to log to the system, it is installed by default on most distribution. Then, after login through ssh, you can kill the running server by using (let's say the executable is CraftBukkit)

> killall CraftBukkit

You can confirm the name of the running process to kill by looking at the process list shown by typing

> ps aux

Next, you can restart the server by calling the command line but add the "screen" command in front. Running the server inside a screen session enables you to always reconnect to the session from anywhere by doing

> screen CraftBukkit param1 param2 ...
// use CTRL-a then d to detach session
> screen -r // will reattach session

If screen is not available on the system install it with

sudo apt-get install screen
share|improve this answer
    
I installed screen. I use a startup script to start the server "~/minecraft/minecraft.sh". So, if I used screen to start the server I would do: "screen mc ~/minecraft/minecraft.sh" and that would create a screen session called "mc" yes? –  Jesse Jul 12 '11 at 19:15
    
If you want to set a session name use the parameter "-S sessionname" –  jmbouffard Jul 12 '11 at 19:29
    
Awesome, thanks! –  Jesse Jul 12 '11 at 19:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.