Running a KF2 Server as a Linux systemd Service
Set up a systemd service for your Killing Floor 2 dedicated server so it starts on boot and restarts automatically after crashes. Includes a complete unit file template and management commands.
Running KF2 as a systemd Service
Running KF2 under systemd gives you automatic restarts on crash, startup on boot, and clean log management — all without screen or tmux.
Step 1 — Create a Dedicated User (Recommended)
Run the server as a non-root user for security:
sudo useradd -m -s /bin/bash steam
Install the server files under /home/steam/kf2server/ as this user.
Step 2 — Create the Service Unit File
Create /etc/systemd/system/kf2server.service:
[Unit]
Description=Killing Floor 2 Dedicated Server
After=network.target
[Service]
Type=simple
User=steam
WorkingDirectory=/home/steam/kf2server
ExecStart=/home/steam/kf2server/Binaries/Win64/KFGameSteamServer.bin.x86_64 \
KF-BioticsLab?game=KFGameContent.KFGameInfo_Survival?difficulty=1?GameLength=1 \
-log
Restart=on-failure
RestartSec=10
KillSignal=SIGTERM
StandardOutput=journal
StandardError=journal
SyslogIdentifier=kf2server
[Install]
WantedBy=multi-user.target
Adjust the map, game mode, and difficulty to your preferred defaults.
Step 3 — Enable and Start the Service
# Reload systemd so it sees the new unit file
sudo systemctl daemon-reload
# Enable: start on boot
sudo systemctl enable kf2server
# Start now
sudo systemctl start kf2server
# Check status
sudo systemctl status kf2server
Managing the Service
| Command | Effect |
|---|---|
sudo systemctl start kf2server |
Start the server |
sudo systemctl stop kf2server |
Stop the server gracefully |
sudo systemctl restart kf2server |
Restart the server |
sudo systemctl status kf2server |
Show running state and last log lines |
journalctl -u kf2server -f |
Follow the live server log |
journalctl -u kf2server -n 100 |
Show last 100 log lines |
Updating the Server
To update KF2 while the service is stopped:
sudo systemctl stop kf2server
sudo -u steam /home/steam/steamcmd/steamcmd.sh \
+force_install_dir /home/steam/kf2server \
+login anonymous \
+app_update 232130 \
+quit
sudo systemctl start kf2server
Or wrap these steps in an update script and call it from a cron job.
Multiple Server Instances
Create separate unit files for each instance — kf2server-1.service, kf2server-2.service, etc. — each with a different port and working directory (or symlinked config pointing to separate port/config combos).
Log Rotation
systemd's journal handles log rotation automatically. Logs are stored in memory + disk by the journal daemon. To limit total KF2 log size:
# View total journal size
journalctl --disk-usage
# Vacuum logs older than 7 days
sudo journalctl --vacuum-time=7d