Problem :
I have a headless Linux server that I connect to through SSH. I recently started using it, in addition to its normal tasks, to host a [game server][1] written in C# with Mono. It performs admirably! However, if I disconnect from my SSH session, it hangs up and game clients disconnect.
To start the game server, I run the command mono KMPServer.exe
. After this, the server software starts and displays configuration information – however, the game server is not running until I type /start
.
I can’t use nohup
because of that – the process of starting the server involves first running it with mono, then interacting with it with it to issue a “/start
” command. Interestingly, I can’t background the process either (Is this normal for Mono?).
Is there any way to run it in a way to keep the game server from closing when I disconnect the SSH session?
Summary:
- The server software (dead link removed) is a third-party multiplayer server (part of a mod) for Kerbal Space Program.
- The Linux server is running Arch Linux x86_64.
- The installed Mono version is 3.2.3
Solution :
Sounds like you should be able to use a screen session. If you are unfamiliar with the screen tool, check out the man pages or visit Screen Command Examples: Get Control of Linux / Unix Terminal.
First, install it with pacman -S screen
. Then start a new session with screen mono KMPServer.exe
, perform all you need to do and detach the session with Ctrl+A+D. If you need to attach the session again, use screen -x
.