📋 命令速查表
| 类别 | 命令 | 说明 |
|---|---|---|
| 启动 | openclaw gateway | 启动 Gateway |
| 停止 | Ctrl+C | 停止 Gateway |
| 重启 | openclaw gateway restart | 重启 Gateway |
| 状态 | openclaw gateway status | 查看 Gateway 状态 |
| 健康检查 | openclaw gateway health | 健康检查 |
| 安装 | openclaw update | 更新 OpenClaw |
| 配置 | openclaw config set <path> <value> | 设置配置 |
| 验证 | openclaw config validate | 验证配置 |
| 插件 | openclaw plugins install @xxx | 安装插件 |
| 频道 | openclaw channels add --channel xxx | 添加频道 |
| 日志 | openclaw channels logs --channel all | 查看日志 |
| 诊断 | openclaw doctor | 运行诊断 |
| 成本 | openclaw gateway usage-cost | 查看使用成本 |
🚀 核心操作命令
1.Gateway 启动/运行
# 启动 Gateway(本地模式)
openclaw gateway# 启动 Gateway(显式形式)
openclaw gateway run# 启动 Gateway(开发模式,不强制配置)
openclaw gateway run --allow-unconfigured --dev# 启动 Gateway 并指定端口
openclaw gateway --port 18789# 启动 Gateway 并绑定到局域网
openclaw gateway --bind lan# 启动 Gateway 并使用 Tailscale
openclaw gateway --tailscale serve
2.Gateway 暂停/停止/重启
# 重启 Gateway(安全模式,等待任务完成)
openclaw gateway restart# 重启 Gateway(强制立即重启)
openclaw gateway restart --force# 重启 Gateway(等待指定时间)
openclaw gateway restart --wait 30s# 重启 Gateway(跳过延迟)
openclaw gateway restart --safe --skip-deferral# 停止 Gateway(需要手动停止进程)
# Windows: Ctrl+C 或关闭终端
# macOS/Linux: Ctrl+C
3.Gateway 状态查询
# 查看Gateway服务状态
openclaw gateway status# 查看Gateway服务状态(JSON格式)
openclaw gateway status --json# 查看Gateway服务状态(深度扫描)
openclaw gateway status --deep# 查看Gateway服务状态(需要RPC权限)
openclaw gateway status --require-rpc# 健康检查(存活检查)
openclaw gateway health# 健康检查(就绪检查)
openclaw gateway health --port 18789# 探测所有目标
openclaw gateway probe# 探测所有目标(JSON格式)
openclaw gateway probe --json
📦 安装与更新
4.安装 OpenClaw
# macOS / Linux
curl -fsSL https://openclaw.ai/install.sh | bash# Windows (PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex# 检查版本
openclaw --version# 更新 OpenClaw
openclaw update
5.首次配置
# 运行引导配置(推荐)
openclaw onboard --install-daemon# 快速启动(跳过引导)
openclaw gateway# 打开控制面板
openclaw dashboard# 手动配置
openclaw configure
⚙️ 配置管理
6.Config 基础操作
# 查看配置文件路径
openclaw config file# 查看配置
openclaw config get <path># 设置配置
openclaw config set <path> <value># 批量设置配置
openclaw config set --batch-json '[...]'# 删除配置
openclaw config unset <path># 查看配置模式
openclaw config schema# 验证配置
openclaw config validate# 查看配置(JSON格式)
openclaw config get <path> --json# 应用补丁文件
openclaw config patch --file ./openclaw.patch.json5# 模拟运行补丁(不实际写入)
openclaw config patch --file ./openclaw.patch.json5 --dry-run
🔌 插件管理
7.Plugin 操作
# 安装插件
openclaw plugins install @openclaw/feishu
openclaw plugins install @openclaw/qqbot
openclaw plugins install "@tencent-weixin/openclaw-weixin"# 列出已安装插件
openclaw plugins list# 启用插件
openclaw config set plugins.entries.<plugin-name>.enabled true# 禁用插件
openclaw config set plugins.entries.<plugin-name>.enabled false
💬 频道管理
8.Channel 操作
# 列出所有频道
openclaw channels list# 列出所有频道(包括未安装的)
openclaw channels list --all# 查看频道状态
openclaw channels status# 查看频道状态(探针模式)
openclaw channels status --probe# 查看频道能力
openclaw channels capabilities# 添加频道
openclaw channels add --channel telegram --token "123:abc"
openclaw channels add --channel qqbot --token "***"# 删除频道
openclaw channels remove --channel telegram --delete# 登录频道(扫码)
openclaw channels login --channel openclaw-weixin
openclaw channels login --channel whatsapp# 登出频道
openclaw channels logout --channel whatsapp# 查看频道日志
openclaw channels logs --channel all
openclaw channels logs --channel discord --lines 100# 解析名称到ID
openclaw channels resolve --channel slack "#general" "@jane"
openclaw channels resolve --channel discord "My Server/#support" "@someone"
👤 Agent 管理
9.Agent 操作
# 添加新 Agent
openclaw agents add <name># 添加新 Agent(非交互模式)
openclaw agents add <name> --model <model-id> --workspace <path># 列出所有 Agent
openclaw agents list# 绑定 Agent 到频道
openclaw agents bind <agent-id> --channel <channel> --peer <peer># 解绑 Agent
openclaw agents unbind <agent-id> --channel <channel>
🔍 诊断与维护
10.诊断命令
# 运行诊断
openclaw doctor# 运行诊断并修复问题
openclaw doctor --fix# 导出诊断报告
openclaw gateway diagnostics export# 导出诊断报告(指定输出路径)
openclaw gateway diagnostics export --output openclaw-diagnostics.zip# 导出诊断报告(JSON格式)
openclaw gateway diagnostics export --json# 查看使用成本
openclaw gateway usage-cost# 查看最近7天的使用成本
openclaw gateway usage-cost --days 7# 查看所有 Agent 的使用成本
openclaw gateway usage-cost --all-agents# 查看稳定性记录
openclaw gateway stability# 查看稳定性记录(指定类型)
openclaw gateway stability --type payload.large# 导出稳定性记录
openclaw gateway stability --bundle latest --export
📊 状态查询
11.状态查询
# 查看整体状态
openclaw status# 查看整体状态(深度扫描)
openclaw status --deep# 查看会话信息
openclaw session_status# 查看会话信息(JSON格式)
openclaw session_status --json# 查看会话历史
openclaw sessions_history --sessionKey <key># 列出所有会话
openclaw sessions_list
📝 其他常用命令
12.其他操作
# 迁移数据
openclaw migrate --from hermes --source ~/.hermes# 打开聊天界面
openclaw chat# 修复配置
openclaw doctor --fix# 查看帮助
openclaw --help
openclaw gateway --help
openclaw channels --help
openclaw config --help
这些就是 OpenClaw 的所有核心操作命令了!如果你想深入了解某个命令的详细参数,可以运行:
openclaw <command> --help比如:
openclaw gateway --help- 查看 Gateway 命令的所有选项openclaw channels add --help- 查看 Channels 添加命令的详细参数