OpenClaw 终端命令详解

OpenClaw 提供了丰富的命令行工具,让你管理 Gateway、配置消息通道、控制 Agent 等。本文详细介绍所有主要命令。

基本用法

Terminal window
openclaw [options] [command]

全局选项

选项说明
--dev开发模式:状态隔离到 ~/.openclaw-dev,默认端口改为 19001
--profile <name>使用命名配置,状态隔离到 ~/.openclaw-<name>
--no-color禁用 ANSI 颜色输出
--log-level <level>日志级别:silent/fatal/error/warn/info/debug/trace
-h, --help显示帮助
-V, --version显示版本号

初始化命令

openclaw setup

初始化配置和工作空间。

Terminal window
openclaw setup # 交互式初始化
openclaw setup --wizard # 启动向导
openclaw setup --workspace <dir> # 指定工作空间路径

openclaw onboard

交互式初始化向导,设置 Gateway、工作空间和技能。

Terminal window
openclaw onboard # 交互式向导
openclaw onboard --install-daemon # 安装并启动守护服务
openclaw onboard --reset # 重置后重新配置

openclaw configure

交互式配置向导(模型、通道、技能、Gateway)。

openclaw config

非交互式配置操作。

Terminal window
openclaw config get <path> # 获取配置值
openclaw config set <path> <value> # 设置配置值
openclaw config unset <path> # 删除配置值
openclaw config file # 显示配置文件路径
openclaw config validate # 验证配置

Gateway 管理

openclaw gateway

管理 WebSocket Gateway 服务。

Terminal window
# 服务管理
openclaw gateway status # 查看状态
openclaw gateway start # 启动服务
openclaw gateway stop # 停止服务
openclaw gateway restart # 重启服务
openclaw gateway install # 安装系统服务
openclaw gateway uninstall # 卸载系统服务
# 运行选项
openclaw gateway --port 18789 # 指定端口
openclaw gateway --bind lan # 绑定地址:loopback/lan/tailnet/auto
openclaw gateway --token <token> # 访问令牌
openclaw gateway --force # 强制杀死占用端口的进程

openclaw logs

查看 Gateway 日志。

Terminal window
openclaw logs --follow # 实时跟踪
openclaw logs --limit 200 # 限制行数
openclaw logs --json # JSON 格式输出

openclaw status

查看会话健康状态和最近收件人。

Terminal window
openclaw status # 基本状态
openclaw status --deep # 深度检查(包含通道探测)
openclaw status --usage # 显示模型用量配额

openclaw health

从运行中的 Gateway 获取健康状态。

Terminal window
openclaw health --json
openclaw health --timeout 5000

消息通道

openclaw channels

管理聊天通道账号。

Terminal window
# 查看和状态
openclaw channels list # 列出已配置通道
openclaw channels status # 检查通道健康
openclaw channels logs # 查看通道日志
# 添加和移除
openclaw channels add --channel telegram --token $TOKEN
openclaw channels add --channel discord --token $TOKEN
openclaw channels remove --channel discord --account work
# 登录登出
openclaw channels login --channel whatsapp
openclaw channels logout --channel whatsapp

支持的通道:whatsapptelegramdiscordslacksignalgooglechatimessagemsteams

消息发送

openclaw message

统一的消息发送接口。

Terminal window
# 发送消息
openclaw message send --target +15555550123 --message "Hi"
openclaw message send --channel discord --target channel:123 --message "Hello"
# 其他操作
openclaw message read --channel whatsapp
openclaw message edit --target <id> --message "New text"
openclaw message delete --target <id>
openclaw message react --target <id> --emoji 👍
# 投票(Discord)
openclaw message poll --channel discord --target channel:123 \
--poll-question "Snack?" --poll-option Pizza --poll-option Sushi

Agent 管理

openclaw agent

运行一次 Agent 对话。

Terminal window
openclaw agent --message "帮我总结今天的新闻"
openclaw agent --to +15555550123 --message "Hello" --deliver
openclaw agent --local # 本地模式(不通过 Gateway)

openclaw agents

管理隔离的 Agent 实例。

Terminal window
openclaw agents list # 列出所有 Agent
openclaw agents add --workspace ./my-agent --model gpt-4
openclaw agents delete <id> # 删除 Agent
openclaw agents bind --agent <id> --bind telegram
openclaw agents unbind --agent <id> --bind telegram

模型配置

openclaw models

管理 AI 模型配置。

Terminal window
# 查看模型
openclaw models list # 列出可用模型
openclaw models status # 模型状态和认证信息
openclaw models status --probe # 实时探测模型可用性
# 设置默认模型
openclaw models set gpt-4 # 设置默认文本模型
openclaw models set-image dall-e-3 # 设置默认图像模型
# 模型别名和回退
openclaw models aliases add fast gpt-3.5-turbo
openclaw models fallbacks add gpt-3.5-turbo
# 认证配置
openclaw models auth add # 交互式添加认证
openclaw models auth setup-token --provider anthropic

定时任务

openclaw cron

管理计划任务。

Terminal window
# 查看任务
openclaw cron status
openclaw cron list
# 添加任务
openclaw cron add --name "daily-report" --every 1d \
--system-event "生成日报"
# 管理任务
openclaw cron enable <id>
openclaw cron disable <id>
openclaw cron rm <id>
openclaw cron run <id> --force # 立即执行

技能管理

openclaw skills

查看和管理技能。

Terminal window
openclaw skills list # 列出所有技能
openclaw skills list --eligible # 只显示可用的技能
openclaw skills info <name> # 查看技能详情
openclaw skills check # 检查技能依赖状态

提示:使用 npx clawhub 搜索和安装更多技能。

浏览器控制

openclaw browser

控制专用浏览器实例。

Terminal window
# 管理浏览器
openclaw browser status
openclaw browser start
openclaw browser stop
# 标签页操作
openclaw browser tabs
openclaw browser open https://example.com
openclaw browser close <targetId>
# 截图和快照
openclaw browser screenshot --full-page
openclaw browser snapshot --format ai
# 页面交互
openclaw browser click <ref>
openclaw browser type <ref> "Hello"
openclaw browser navigate https://example.com

节点管理

openclaw node

管理无头节点主机服务。

Terminal window
openclaw node run --host gateway-host --port 18789
openclaw node status
openclaw node install
openclaw node uninstall

openclaw nodes

与已配对的节点交互。

Terminal window
openclaw nodes list # 列出已配对节点
openclaw nodes pending # 待审批请求
openclaw nodes approve <requestId>
openclaw nodes run --node <id> ls -la # 在节点上执行命令
# 摄像头和屏幕
openclaw nodes camera snap --node <id>
openclaw nodes screen record --node <id> --duration 10s
# 通知
openclaw nodes notify --node <id> --title "提醒" --body "消息内容"

诊断工具

openclaw doctor

健康检查和快速修复。

Terminal window
openclaw doctor # 交互式检查
openclaw doctor --deep # 深度扫描
openclaw doctor --non-interactive # 非交互模式

openclaw security

安全审计工具。

Terminal window
openclaw security audit # 审计配置和状态
openclaw security audit --deep # 深度探测
openclaw security audit --fix # 自动修复安全问题

其他实用命令

openclaw dashboard

打开浏览器控制面板。

openclaw tui

打开终端用户界面。

Terminal window
openclaw tui
openclaw tui --session <key>
openclaw tui --thinking high

openclaw docs

搜索官方文档。

Terminal window
openclaw docs gateway
openclaw docs "how to setup telegram"

openclaw qr

生成 iOS 配对二维码。

openclaw backup

创建和验证备份。

Terminal window
openclaw backup create
openclaw backup verify <archive>

openclaw reset

重置本地配置和状态。

Terminal window
openclaw reset --scope config # 只重置配置
openclaw reset --scope full # 完全重置

openclaw update

更新 OpenClaw。

Terminal window
openclaw update
openclaw update --check # 检查更新

命令速查表

类别命令说明
初始化setup, onboard, configure安装和配置
Gatewaygateway, logs, status, health服务管理
通道channels, message消息通道
Agentagent, agentsAI 助手
模型modelsAI 模型配置
定时cron计划任务
技能skills技能管理
浏览器browser浏览器控制
节点node, nodes远程节点
诊断doctor, security健康检查
其他dashboard, tui, docs, qr工具

更多详情请访问 OpenClaw 官方文档

参考链接


← Back to blog