
⚡⚡⚡ 新年新文⚡⚡⚡
文章目录
-
- 1,核心状态与诊断命令
-
- 1.1,核心状态解读
- 1.2,命令
- 2,服务管理命令 (Systemd User Mode)
- 3,配置与文件路径速查
- 4,常见运维场景实操
1,核心状态与诊断命令
1.1,核心状态解读
openclaw gateway status
[root@tigerhhzz03 bin]# openclaw gateway status
🦞 OpenClaw 2026.2.3-1 (d84eb46) — If it works, it's automation; if it breaks, it's a "learning opportunity."
│
◇
Service: systemd (enabled)
File logs: /tmp/openclaw/openclaw-2026-03-02.log
Command: /usr/bin/node /usr/lib/node_modules/openclaw/dist/index.js gateway –port 18789
Service file: ~/.config/systemd/user/openclaw-gateway.service
Service env: OPENCLAW_GATEWAY_PORT=18789
Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json
Gateway: bind=lan (0.0.0.0), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Local probe uses loopback (127.0.0.1). bind=lan listens on 0.0.0.0 (all interfaces); use a LAN IP for remote clients.
Runtime: running (pid 1090355, state active, sub running, last exit 0, reason 0)
RPC probe: ok
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
1.2,命令
命令用于检查服务是否健康、获取 Token 和排查问题。
| 查看网关状态 | openclaw gateway status | 最常用。查看运行状态、PID、端口、配置文件路径及 Dashboard 地址。 |
| 查看探针状态 | openclaw probe status | 检查 OpenClaw 是否能成功连接到后端的 AI 模型或工具。 |
| 一键诊断 | openclaw status | 运行全面的自我诊断,报告潜在问题(Troubles)。 |
| 查看版本 | openclaw –version | 查看当前安装的版本号。 |
| 查看帮助 | openclaw –help | 查看所有可用命令列表。 |
| 查看子命令帮助 | openclaw gateway –help | 查看 gateway 子命令的具体用法。 |
2,服务管理命令 (Systemd User Mode)
由于服务文件位于 ~/.config/systemd/user/,不需要 sudo,但必须使用 –user 标志(或者确保当前用户就是运行服务的用户,即 root)。
| 重启服务 | systemctl –user restart openclaw-gateway | 修改配置后必须执行此命令生效。 |
| 停止服务 | systemctl –user stop openclaw-gateway | 暂时关闭服务。 |
| 启动服务 | systemctl –user start openclaw-gateway | 启动服务。 |
| 查看实时日志 | journalctl –user -u openclaw-gateway -f | 调试神器。 -f 表示跟随输出最新日志,类似 tail -f。 |
| 查看最近日志 | journalctl –user -u openclaw-gateway -n 50 | 查看最近 50 行日志。 |
| 开机自启 | systemctl –user enable openclaw-gateway | 设置开机自动启动(需配合 loginctl enable-linger)。 |
| 取消自启 | systemctl –user disable openclaw-gateway | 取消开机自动启动。 |
| 重载配置 | systemctl –user daemon-reload | 如果修改了 service 文件本身,需运行此命令。 |
关于开机自启 用户级服务 (–user) 默认在用户注销后会停止。如果你希望 root 用户注销 SSH 后服务依然运行,必须执行一次:
bash loginctl enable-linger root
3,配置与文件路径速查
根据你的状态输出,关键文件位置如下,方便你直接编辑:
| 主配置文件 | ~/.openclaw/openclaw.json(即 /root/.openclaw/openclaw.json) | 修改端口、绑定 IP、API Key 等核心参数。修改后需重启服务。 |
| 日志文件 | /tmp/openclaw/openclaw-YYYY-MM-DD.log | 直接 cat 或 tail -f 查看。注意 /tmp 目录重启可能清空,重要日志建议备份。 |
| 服务定义文件 | ~/.config/systemd/user/openclaw-gateway.service | 一般不需要手动修改,除非要改环境变量或启动参数。 |
| 程序源码 | /usr/lib/node_modules/openclaw | Node.js 模块所在目录,一般无需触碰。 |
| 启动命令 | /usr/bin/node … | 实际运行的底层命令。 |
4,常见运维场景实操
场景 A:修改了配置文件,想生效
# 1. 编辑配置
vi ~/.openclaw/openclaw.json
# 2. 重启服务
systemctl –user restart openclaw-gateway
# 3. 确认状态
openclaw gateway status
场景 B:服务起不来,要看报错
# 实时查看报错日志
journalctl –user -u openclaw-gateway -f
# 或者查看具体的日志文件
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log
场景 C:忘记 Token 了,要重新获取
# 在日志中搜索 token
grep "token" /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log
# 或者
journalctl –user -u openclaw-gateway | grep "token"
场景 D:彻底卸载 (如果需要)
# 1. 停止并禁用服务
systemctl –user stop openclaw-gateway
systemctl –user disable openclaw-gateway
# 2. 删除 Node 模块
npm uninstall -g openclaw
# 或者手动删除
rm -rf /usr/lib/node_modules/openclaw
rm /usr/bin/openclaw
# 3. 删除配置和日志
rm -rf ~/.openclaw
rm -rf /tmp/openclaw
rm ~/.config/systemd/user/openclaw-gateway.service
systemctl –user daemon-reload
感谢阅读,下期更精彩 👋👋👋


