Running the server 24/7 without PuTTY

Ask questions about dedicated servers here and we and other users will do our best to answer them. Please also refer to the self-help section for tutorials and answers to the most commonly asked questions.
Post Reply
blue2kx
A semi-regular
A semi-regular
Posts: 16
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sat Nov 21, 2009 7:19 pm

Running the server 24/7 without PuTTY

Post by blue2kx »

How do I run a game server 24/7 without having PuTTY on? I can't have my computer online 24/7 and that seems impractical for everyone to do so I'm guessing there's a different way to do this.
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Running the server 24/7 without PuTTY

Post by Edge100x »

To do this, I recommend using the "screen" utility. Start your server with a command like this:

Code: Select all

screen -AmdS screenname yourcommandline
Where "screenname" is an identifier you want to use for the screen (so that you can reconnect to it later) and "yourcommandline" is the command line that you've been using already to start up your server.

This will start the server, but hide it from view, putting you right back to another command prompt. To connect to the screen session you just created (and see the server's console), just use this command:

Code: Select all

screen -r screenname
To hide the screen session again, hold down the control key and hit "a"; then, let go of both keys and hit "d". You should see the message "[detached]" and be returned to the normal command prompt.

While your screen is detached, you can exit your SSH window and it will continue running on the server.

If you exit the game server (such as with Control-C), the screen session will close.

A few other useful commands to get you going:

Code: Select all

screen -ls
Shows a list of running (and detached) screens.

Code: Select all

screen -DR screenname
Detach a screen remotely and then reattach it to your session (if you left it attached in a window on a different machine, or your SSH connection was interrupted, this can be very useful to recover it).

Control-a, Escape will let you cursor through the screen buffer while you are attached to a screen. Hitting Escape again will get you back out.
blue2kx
A semi-regular
A semi-regular
Posts: 16
Joined: Sat Nov 21, 2009 7:19 pm

Re: Running the server 24/7 without PuTTY

Post by blue2kx »

Wonderful. Thanks!
blue2kx
A semi-regular
A semi-regular
Posts: 16
Joined: Sat Nov 21, 2009 7:19 pm

Re: Running the server 24/7 without PuTTY

Post by blue2kx »

Ah, can't edit my post but I wanted to know why a screen might die? I tried this but I was able to run it but after a while, it showed the screen as being dead:

Code: Select all

There is a screen on:
4419.cs (Dead ???)
blue2kx
A semi-regular
A semi-regular
Posts: 16
Joined: Sat Nov 21, 2009 7:19 pm

Re: Running the server 24/7 without PuTTY

Post by blue2kx »

Oh, I set it up last night before the maintenance and I was just able to check it tonight, that might've been the cause but I'm just making sure.

Extremely sorry for the triple post :roll:
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Running the server 24/7 without PuTTY

Post by Edge100x »

A machine crash will cause dead screens like that; if we weren't able to log in to shut down your server gracefully during a maintenance event (that is, if the password didn't match what was on the Server control page), the virtual machine would think it crashed, and this would happen. To remove them from the list, use this command:

Code: Select all

screen -wipe
rustydusty1717
This is my homepage
This is my homepage
Posts: 645
Joined: Sun Sep 20, 2009 6:15 pm

Re: Running the server 24/7 without PuTTY

Post by rustydusty1717 »

I tried to do the screen option on my VPS and no such luck. It seems screen isn't installed. I'm running CentOS 5 though, not Gen. I ending up just all my command lines normally, then adding '&' at the end to keep it running.
Image
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Running the server 24/7 without PuTTY

Post by Edge100x »

I haven't tried it, but you could likely install screen in CentOS with a command like:

Code: Select all

yum install screen
rustydusty1717
This is my homepage
This is my homepage
Posts: 645
Joined: Sun Sep 20, 2009 6:15 pm

Re: Running the server 24/7 without PuTTY

Post by rustydusty1717 »

Took 6 seconds flat, nice! 8)
Image
Post Reply