Running Project Zomboid Server as a systemd Service
Configure Project Zomboid's dedicated server as a systemd service for automatic startup, crash recovery, and clean shutdown. Includes a complete unit file with logging.
Project Zomboid Server as a systemd Service
Running the server as a systemd service gives you automatic startup on boot, crash recovery, and clean log management.
Prerequisites
Create a dedicated user for the server (recommended):
sudo useradd -m -s /bin/bash pzserver
sudo su - pzserver
Install SteamCMD and the server files as this user to /home/pzserver/pz/.
Unit File
Create /etc/systemd/system/pzserver.service:
[Unit]
Description=Project Zomboid Dedicated Server
After=network.target
[Service]
Type=simple
User=pzserver
Group=pzserver
WorkingDirectory=/home/pzserver/pz
ExecStart=/home/pzserver/pz/start-server.sh -servername servertest
ExecStop=/bin/kill -s SIGTERM $MAINPID
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=pzserver
# Give the process time to save the world on shutdown
TimeoutStopSec=120
[Install]
WantedBy=multi-user.target
Enabling and Starting
sudo systemctl daemon-reload
sudo systemctl enable pzserver
sudo systemctl start pzserver
sudo systemctl status pzserver
Viewing Logs
# Live log stream
sudo journalctl -u pzserver -f
# Last 100 lines
sudo journalctl -u pzserver -n 100
# Logs since last boot
sudo journalctl -u pzserver -b
Managing the Service
sudo systemctl stop pzserver # Graceful stop (waits up to 120s for world save)
sudo systemctl restart pzserver # Stop and start
sudo systemctl status pzserver # Current state and recent log lines
Automatic Updates
To update the server before each start, use a wrapper script instead of calling start-server.sh directly:
# /home/pzserver/start-pz-with-update.sh
#!/bin/bash
/home/pzserver/steamcmd/steamcmd.sh \
+force_install_dir /home/pzserver/pz \
+login anonymous \
+app_update 380870 \
+quit
exec /home/pzserver/pz/start-server.sh -servername servertest
chmod +x /home/pzserver/start-pz-with-update.sh
Then update the unit file's ExecStart to point to this wrapper script.
Save-on-Shutdown
The SIGTERM stop command and TimeoutStopSec=120 give the server up to 2 minutes to finish saving the world before systemd force-kills it. Project Zomboid saves the world before shutting down cleanly, so this window is usually sufficient.