Game Server 24.7

August 5, 2013 6.3k views
Hi, I'm running a Counter-Strike: Source gameserver but when I close the putty client, the server just shuts down , sometimes when i close it doesn't shut down which is weird, so all goes well, ubt whenever the server gets no activity for lets say, 30 minutes , i just shuts down, how can I keep my CS:s server up 24/7? Is there something I need to add to the command line to keep it up 24/7? Here's my current command line: ./srcds_run -game cstrike +port 27015 +maxplayers 16 +map de_dust2 -secure
1 comment
  • Add '&' at the end of your command line. This will launch the command in background.

    At this time, your server is shutting down because your command is attach to your SSH prompt.

10 Answers
Install and use screen. Screen creates a virtual console that doesn't close when putty closes.

Login with putty
run screen
run your game server
Then disconnect from putty or press ctrl+a+d to detach from the screen.
To re-attach run 'screen -r'
This will keep my server on 24.7 even when players aren't online?
Yes, it will.
Otherwise he wouldn't tell you ;).
Sorry for the double post, helping you to run you a screen command (install screen first, google it).

Then run your Counter Strike through this:

screen -A -m -d -S SCREENNAME ./srcds_run -game cstrike +port 27015 +maxplayers 16 +map de_dust2 -secure

SCREENNAME is the name of your counter strike screen.
For example "CSServer".
re-attach to your screen with "screen -r" without quotes. It should work, unless you are running multiple servers of CS.
you can list your screens with this command: "screen -ls" without the quotes.

How do I make a screen name?
Thanks, the server is running, but hopefully it doesn't crash when inactive like usual, I'll see how it goes.
Sorry for triple post, I have another question, how do I access the console in my SSH while the server is running?
@bgclan: Once you run the gameserver, you should detach the screen session by pressing ctrl +a, d. You should be back to your shell once you do that. You can then disconnect and the server will still be running.
Don't do any of that.

Just run:

./srcds_run -game cstrike +port 27015 +maxplayers 16 +map de_dust2 -secure > /dev/null 2>&1 &

The issue is your server trying to write to the output pipe and it not being available since the ssh session is closed. Just pipe your output to dev null instead, the server will still have logs, it just won't log back to console and crash.
Have another answer? Share your knowledge.