一、什么是OpenClaw?
OpenClaw 是一款强大的 AI 助手平台,通过命令行(CLI)可以管理 AI 对话、频道连接、定时任务、浏览器控制等功能。掌握常用命令,能让你更高效地使用 OpenClaw。

二、基础命令
1. 查看版本
openclaw –version
# 或简写
openclaw -v
2. 查看状态
# 快速查看运行状态
openclaw status
# 深度诊断(包含频道连通性检测)
openclaw status –deep
# 查看模型用量
openclaw status –usage
# 输出完整诊断信息(方便粘贴给技术支持)
openclaw status –all
3. 健康检查
openclaw health
4. 查看日志
# 实时追踪日志
openclaw logs –follow
# 查看最近 200 条日志
openclaw logs –limit 200
# 输出纯文本格式
openclaw logs –plain
三、Gateway 服务管理
Gateway 是 OpenClaw 的核心服务,负责处理所有 AI 对话和消息路由。
1. 服务状态
openclaw gateway status
2. 启动 / 停止 / 重启
# 启动服务
openclaw gateway start
# 停止服务
openclaw gateway stop
# 重启服务
openclaw gateway restart
3. 安装 / 卸载服务
# 安装为系统服务(开机自启)
openclaw gateway install
# 卸载系统服务
openclaw gateway uninstall
四、配置管理
1. 查看配置
# 查看某个配置项
openclaw config get Agents.defaults.model.primary
# 查看配置文件路径
openclaw config file
2. 修改配置
# 设置某个配置项
openclaw config set agents.defaults.model.primary claude-3-5-sonnet
# 删除某个配置项
openclaw config unset agents.defaults.model.primary
3. 验证配置
openclaw config validate
4. 交互式配置向导
openclaw configure
五、模型管理
1. 查看模型状态
openclaw models status
# 输出 JSON 格式
openclaw models status –json
2. 列出可用模型
openclaw models list
# 列出所有模型(包括未启用的)
openclaw models list –all
3. 设置默认模型
# 设置主模型
openclaw models set claude-3-5-sonnet-20241022
# 设置图像模型
openclaw models set-image dall-e-3
4. 模型认证
# 添加认证
openclaw models auth add
# 使用 setup-token 认证(Anthropic)
openclaw models auth setup-token –provider anthropic
六、频道管理
OpenClaw支持 WhatsApp、Telegram、Discord、Slack 等多个聊天频道。
1. 查看频道列表
openclaw channels list
2. 查看频道状态
openclaw channels status
# 深度检测
openclaw channels status –probe
3. 添加频道
# 添加 Telegram 频道
openclaw channels add –channel telegram –token YOUR_BOT_TOKEN
# 添加 Discord 频道
openclaw channels add –channel discord –token YOUR_BOT_TOKEN
# 添加WhatsApp(交互式)
openclaw channels add –channel whatsapp
4. 删除频道
openclaw channels remove –channel telegram –delete
5. 登录 / 登出
# WhatsApp 登录(扫码)
openclaw channels login –channel whatsapp
# 登出
openclaw channels logout –channel whatsapp
6. 查看频道日志
openclaw channels logs
# 查看指定频道日志
openclaw channels logs –channel telegram –lines 100
七、发送消息
# 发送消息到指定号码
openclaw message send –target +8613800138000 –message "你好!"
# 发送到 Discord 频道
openclaw message send –channel discord –target channel:123456 –message "Hello!"
八、定时任务(Cron)
1. 查看定时任务
openclaw cron list
# 包含已禁用的任务
openclaw cron list –all
2. 添加定时任务
# 每天早上 9 点发送消息
openclaw cron add –name "早安提醒" –cron "0 9 * * *" –system-event "早安!今天也要加油哦"
# 30 分钟后执行一次
openclaw cron add –name "提醒" –every 1800000 –system-event "该休息了"
3. 启用 / 禁用任务
openclaw cron enable <任务ID>
openclaw cron disable <任务ID>
4. 立即执行任务
openclaw cron run <任务ID>
5. 删除任务
openclaw cron rm <任务ID>
6. 查看任务执行历史
openclaw cron runs –id <任务ID>
九、会话管理
# 查看所有会话
openclaw sessions
# 查看最近活跃的会话(30分钟内)
openclaw sessions –active 30
# JSON 格式输出
openclaw sessions –json
十、技能管理
1. 查看已安装技能
openclaw skills list
# 只显示可用的技能
openclaw skills list –eligible
2. 查看技能详情
openclaw skills info <技能名称>
3. 检查技能状态
openclaw skills check
十一、插件管理
1. 查看插件列表
openclaw plugins list
2. 安装插件
openclaw plugins install <插件路径或名称>
3. 启用 / 禁用插件
openclaw plugins enable <插件ID>
openclaw plugins disable <插件ID>
4. 插件诊断
openclaw plugins doctor
十二、浏览器控制
OpenClaw内置浏览器控制功能,可以自动化网页操作。
1. 基础操作
# 查看浏览器状态
openclaw browser status
# 启动浏览器
openclaw browser start
# 停止浏览器
openclaw browser stop
# 打开网页
openclaw browser open https://www.example.com
# 查看当前标签页
openclaw browser tabs
2. 截图
# 截取当前页面
openclaw browser screenshot
# 截取完整页面(含滚动区域)
openclaw browser screenshot –full-page
3. 页面操作
# 导航到指定 URL
openclaw browser navigate https://www.example.com
# 点击元素
openclaw browser click <元素ref>
# 输入文字
openclaw browser type <元素ref> "要输入的文字"
# 按键
openclaw browser press Enter
十三、内存管理
# 查看内存索引状态
openclaw memory status
# 重新索引内存文件
openclaw memory index
# 搜索内存
openclaw memory search "关键词"
十四、安全审计
# 基础安全审计
openclaw security audit
# 深度审计(包含实时探测)
openclaw security audit –deep
# 自动修复安全问题
openclaw security audit –fix
十五、初始化与重置
1. 初始化设置
# 首次安装向导
openclaw setup
# 完整引导向导
openclaw onboard
2. 诊断修复
openclaw doctor
3. 重置配置
# 重置配置(保留数据)
openclaw reset –scope config
# 重置配置+凭证+会话
openclaw reset –scope config+creds+sessions
# 完全重置
openclaw reset –scope full –yes
十六、常用命令速查表
|
命令 |
说明 |
|
openclaw status |
查看运行状态 |
|
openclaw status –deep |
深度诊断 |
|
openclaw gateway restart |
重启服务 |
|
openclaw logs –follow |
实时查看日志 |
|
openclaw channels list |
查看频道列表 |
|
openclaw models list |
查看可用模型 |
|
openclaw cron list |
查看定时任务 |
|
openclaw sessions |
查看会话列表 |
|
openclaw skills list |
查看技能列表 |
|
openclaw plugins list |
查看插件列表 |
|
openclaw memory search "关键词" |
搜索记忆 |
|
openclaw security audit |
安全审计 |
|
openclaw doctor |
诊断修复 |
|
openclaw config get <路径> |
查看配置 |
|
openclaw config set <路径> <值> |
修改配置 |
十七、小技巧
1. 使用 –json 获取结构化输出
大多数命令支持–json参数,方便脚本处理:
openclaw channels list –json
openclaw models list –json
openclaw cron list –json
2. 全局参数
# 禁用颜色输出(适合日志记录)
openclaw –no-color status
# 使用独立配置文件(多实例)
openclaw –profile work status
3. 查看帮助
# 查看某个命令的帮助
openclaw gateway –help
openclaw cron –help
openclaw channels –help


