Running OpenClaw as a systemd Service: Always-On Linux Setup
|6 min read
Table of Contents
Haven't installed OpenClaw yet?
curl -fsSL https://openclaw.ai/install.sh | bash
iwr -useb https://openclaw.ai/install.ps1 | iex
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Worried it'll affect your machine? ClawTank — cloud deploy in 60s, zero risk to your files.
Running OpenClaw as a systemd Service: Always-On Linux Setup
Running OpenClaw interactively in a terminal works during development, but for any serious deployment you want it running as a background service that starts on boot, restarts on failure, and produces structured logs. On modern Linux, systemd is the standard process supervisor for all of this.
Why systemd for OpenClaw?
systemd is the init system on virtually every modern Linux distribution[1]. Using it gives you:
Automatic startup on boot without manual intervention
Automatic restart when the process crashes
Structured logging via the journal with built-in rotation
Resource controls through cgroups (memory limits, CPU quotas)
Dependency ordering so OpenClaw starts after networking is available
Security sandboxing to restrict file system and network access
Compared to running openclaw start & in tmux or a cron @reboot entry, systemd provides reliability guarantees that ad-hoc approaches cannot match.
Quick Setup: The Built-in Installer
openclaw onboard --install-daemon
This detects whether you are root or a regular user, creates the appropriate service file, enables it for boot, and starts it immediately. For many users, this is all you need.
User vs System Services
System services live in /etc/systemd/system/ and start at boot regardless of login state. Choose this for headless servers and shared machines.
User services live in ~/.config/systemd/user/ and start when the user logs in. Choose this for personal workstations or when you lack root access.
Manual System Service File
First, locate your paths:
which openclaw
# /usr/bin/openclaw or ~/.nvm/versions/node/v22.x.x/bin/openclaw
# Follow logs in real time
sudo journalctl -u openclaw.service -f
# Logs since last boot
sudo journalctl -u openclaw.service -b
# Logs from the last hour
sudo journalctl -u openclaw.service --since "1 hour ago"
# Only errors
sudo journalctl -u openclaw.service -p err
Configure log retention:
sudo tee -a /etc/systemd/journald.conf > /dev/null << 'EOF'
SystemMaxUse=500M
MaxRetentionSec=30day
EOF
sudo systemctl restart systemd-journald
Resource Limits
systemd integrates with Linux cgroups to enforce hard resource limits:
Restart=on-failure # Restart on non-zero exit only
RestartSec=5 # Wait 5 seconds between attempts
StartLimitIntervalSec=300
StartLimitBurst=5 # Max 5 failures per 5 minutes
If OpenClaw sometimes exits with code 0 unexpectedly, switch to Restart=always with RestartPreventExitStatus=SIGTERM so systemctl stop still works cleanly.
For a single instance on a dedicated machine, systemd is simplest. For multiple isolated instances, Docker (or ClawTank for managed hosting) is the better fit[4].
The - prefix on EnvironmentFile=-/etc/openclaw/env means systemd will not fail if the file does not exist.
Summary
systemd gives you everything needed to run OpenClaw reliably: boot startup, crash recovery, structured logging, and resource controls. The built-in openclaw onboard --install-daemon handles the common case. For advanced deployments, the manual service file lets you tune every aspect of the runtime environment.