Docs / Game Servers / Automating Game Server Updates with SteamCMD

Automating Game Server Updates with SteamCMD

By Admin · Mar 1, 2026 · Updated Apr 24, 2026 · 27 views · 2 min read

Why Automate Updates?

Game servers need regular updates to stay compatible with game clients. Automating updates ensures your server is always running the latest version without manual intervention.

Basic Update Script

#!/bin/bash
# /opt/gameserver/update.sh
APP_ID=896660  # Change to your game's App ID
INSTALL_DIR=/opt/gameserver/server
SERVICE_NAME=valheim  # Change to your service name

echo "$(date) - Checking for updates..."

# Stop the server
sudo systemctl stop $SERVICE_NAME

# Run SteamCMD update
steamcmd +force_install_dir $INSTALL_DIR \
  +login anonymous \
  +app_update $APP_ID validate \
  +quit

# Start the server
sudo systemctl start $SERVICE_NAME

echo "$(date) - Update complete"

Scheduling with Cron

# Update daily at 4 AM
0 4 * * * /opt/gameserver/update.sh >> /var/log/gameserver-update.log 2>&1

Update Only If Needed

To avoid unnecessary restarts, check if an update is actually available:

#!/bin/bash
APP_ID=896660
INSTALL_DIR=/opt/gameserver/server

# Check for updates without downloading
UPDATE_CHECK=$(steamcmd +force_install_dir $INSTALL_DIR \
  +login anonymous \
  +app_status $APP_ID \
  +quit 2>&1)

if echo "$UPDATE_CHECK" | grep -q "Update Required"; then
  echo "$(date) - Update available, updating..."
  sudo systemctl stop valheim
  steamcmd +force_install_dir $INSTALL_DIR \
    +login anonymous +app_update $APP_ID +quit
  sudo systemctl start valheim
  echo "$(date) - Update applied"
else
  echo "$(date) - Server is up to date"
fi

Pre-Update Backup

Always back up save data before updating:

#!/bin/bash
BACKUP_DIR=/opt/backups/gameserver
SAVE_DIR=/opt/gameserver/saves
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p $BACKUP_DIR
tar czf $BACKUP_DIR/saves-$DATE.tar.gz -C $SAVE_DIR .

# Keep only last 7 backups
ls -t $BACKUP_DIR/*.tar.gz | tail -n +8 | xargs rm -f 2>/dev/null

Discord Notifications

Send a message to your Discord server when updates happen:

WEBHOOK_URL="https://discord.com/api/webhooks/YOUR_WEBHOOK"
curl -H "Content-Type: application/json" \
  -d '{"content":"Server updated and restarted!"}' \
  $WEBHOOK_URL

Was this article helpful?