Guide Menu expand_more
install vps
Run OpenClaw After Logout
Understand PM2, systemd, logs, and restart behavior so OpenClaw keeps running after your SSH session ends.
Why daemonize OpenClaw?
When you start OpenClaw using standard commands like npm run start or node index.js, the process binds directly to your SSH session. When you disconnect or close your laptop, the OS kills that session—which shuts down OpenClaw, breaking your Telegram bot, WhatsApp responders, and web dashboards.
To keep it running 24/7, you must “daemonize” it (run it in the background as a system service).
Hinglish Summary: Agar aap normal bash terminal mein command run karenge, toh terminal close hone par OpenClaw bhi crash/stop ho jayega. background mein 24/7 chalane ke liye humein PM2 ya systemd service use karni padegi.
Method A: PM2 (Quick & Recommended for Node setups)
PM2 is a dedicated production process manager for Node.js applications. It handles auto-restarts, environment variables, log rotation, and cluster modes.
Step 1: Install PM2 globally
Make sure you are logged in as your non-root deployment user and run:
npm install -g pm2
Step 2: Start OpenClaw Gateway
Navigate to your OpenClaw folder and start the process:
cd ~/openclaw-setup
pm2 start npm --name "openclaw-gateway" -- run start
Step 3: Verify the process is running
List all PM2 processes:
pm2 status
You should see openclaw-gateway listed with an online status.
Step 4: Configure system startup persistence
To ensure PM2 and OpenClaw start automatically if the VPS reboots:
pm2 startup
This command generates a terminal script. Copy and paste that generated command into your terminal to configure system-level integration, then save the current process list:
pm2 save
Step 5: Check logs
To see real-time console prints and incoming webhooks:
pm2 logs openclaw-gateway
Method B: systemd (Native Linux Service)
If you prefer native Ubuntu/Linux services and want to manage OpenClaw with standard systemctl commands, create a custom systemd unit file.
Step 1: Create the service file
Use nano or vi with root permissions to create the config:
sudo nano /etc/systemd/system/openclaw.service
Step 2: Paste the following template
Modify /home/ubuntu/openclaw-setup, ubuntu, and paths depending on your username and installation path.
[Unit]
Description=OpenClaw Gateway Service
After=network.target redis-server.service
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/openclaw-setup
ExecStart=/usr/bin/npm run start
Restart=on-failure
RestartSec=5s
Environment=NODE_ENV=production
# Security restrictions to harden the service
ProtectSystem=full
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[!IMPORTANT] If you used NVM to install Node, the path
/usr/bin/npmmay not exist or point to an older Node runtime. In your service file, replace/usr/bin/npmwith the absolute path to your NVM npm executable (e.g./home/ubuntu/.nvm/versions/node/v24.x.y/bin/npm).
Step 3: Reload and start the service
Run these commands to activate the unit:
sudo systemctl daemon-reload
sudo systemctl enable openclaw.service
sudo systemctl start openclaw.service
Step 4: Check service status
sudo systemctl status openclaw.service
Step 5: Read systemd logs
To check process outputs and debug connection failures:
journalctl -u openclaw.service -f -n 100
Safety Guidelines
- Do not run as root: Always specify a standard user (like
ubuntuoropenclaw) in your service configs. Running as root gives any potential dashboard security flaw complete system write access. - Setup log rotation: Logs can fill up disk space quickly over months. If using PM2, install the rotation plugin:
pm2 install pm2-logrotate ClawReady.in is an independent educational resource and setup service. It is not affiliated with, endorsed by, or operated by OpenClaw.