OpenClaw 常用命令速查指南
装好了 OpenClaw,怎么用?这篇把最常用的命令讲清楚,从入门到进阶。
写在前面
OpenClaw 的核心是 Gateway——一个长期运行的后台进程,负责接收消息、调用 AI、执行工具。大部分操作都通过终端命令行完成,但也提供了漂亮的 Web 控制台。
💡 所有命令在
openclaw --help里都能看到完整列表,这篇挑最实用的讲。
一、启动与状态
启动 Gateway
这是 OpenClaw 的主进程,启动后一直在后台运行:
openclaw gateway # 前台运行openclaw gateway start # 后台服务运行(推荐)openclaw gateway stop # 停止服务openclaw gateway restart # 重启服务
查看状态
openclaw status # 整体运行状态openclaw gateway status # Gateway 详情 (bind、端口、连接)openclaw --version # 查看版本号openclaw doctor # 诊断配置问题
二、配置管理
OpenClaw 的配置存在 ~/.openclaw/openclaw.json 里,通过命令行读写:
读写配置
openclaw config get gateway.bind # 查看绑定模式openclaw config get providers # 查看 AI 模型配置openclaw config get channels # 查看通信渠道配置openclaw config get cron # 查看定时任务openclaw config get agents.default # 查看默认 Agent 配置
写入配置
openclaw config set gateway.bind lan # 设为局域网可访问openclaw config set gateway.auth.token "my-token" # 设置认证令牌openclaw config set providers.deepseek.apiKey "sk-xxx" # 配模型 Key
其他操作
openclaw config unset gateway.customBindHost # 删除配置项openclaw config get --all # 查看全部配置
常见误区:
gateway.bind不填 IP 地址,而是填模式名:loopback(仅本机)、lan(0.0.0.0)、tailnet、custom(需配合customBindHost)。
三、通信渠道
OpenClaw 支持接入多个聊天平台,配置好后在聊天软件里就能直接和 AI 对话。
QQ 机器人
openclaw config set channels.qqbot.enabled trueopenclaw config set channels.qqbot.appId "你的AppID"openclaw config set channels.qqbot.token "你的Token"openclaw gateway restart
配置后重启 Gateway,QQ 上就多了一个可以随时差遣的 AI 助手。
Telegram / Discord / Signal
类似的方式,配置对应的 channel 字段即可(channels.telegram、channels.discord、channels.signal)。
Web 控制台(零配置)
Gateway 启动后浏览器打开以下地址即可直接聊天:
http://localhost:18789/__openclaw__/
四、定时任务(Cron)
这是 OpenClaw 最有价值的功能之一——让 AI 在指定时间自动干活。
创建定时任务
openclaw cron add \--name "Morning Brief" \--cron "0 7 * * *" \--tz "Asia/Shanghai" \--session isolated \--message "生成今日科技新闻简报" \--announce \--channel qqbot \--to "user:你的QQ号"
参数说明:
-
–name:任务名称 -
–cron:cron 表达式(分 时 日 月 周) -
–tz:时区 -
–session isolated:在独立 session 中执行(不影响主会话) -
–message:告诉 AI 要干什么 -
–announce –channel qqbot –to “user:xxx”:结果推送到 QQ
管理定时任务
openclaw cron list # 列出所有任务openclaw cron show <job-id> # 查看某任务详情openclaw cron runs --id <job-id> # 查看运行历史openclaw cron remove <job-id> # 删除任务
五、AI 模型配置
配置 DeepSeek(推荐,性价比最高)
openclaw config set agents.default.defaultSettings.modelProvider deepseekopenclaw config set agents.default.defaultSettings.model deepseek/deepseek-chatopenclaw config set providers.deepseek.apiKey "sk-你的Key"
配置 OpenAI
openclaw config set agents.default.defaultSettings.modelProvideropenai openclaw config set agents.default.defaultSettings.model openai/gpt-4oopenclaw config set providers.openai.apiKey "sk-你的Key"
六、多设备联动(Node 模式)
把 Ubuntu 服务器、树莓派、旧手机当成 OpenClaw 的执行节点。
让另一台设备连接为主 Gateway 的 Node
主设备(macOS):
# 设置 Gateway 为 LAN 模式openclaw config set gateway.bind lanopenclaw config set gateway.auth.token "my-token"openclaw gateway restart
从设备(Ubuntu):
export OPENCLAW_GATEWAY_TOKEN="my-token"openclaw node run --host 192.168.1.16 --port 18789 --display-name "Ubuntu-Server"
家庭局域网也可加环境变量跳过安全警告:
export OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1export OPENCLAW_GATEWAY_TOKEN="my-token"openclaw node run --host 192.168.1.16 --port 18789 --display-name "Ubuntu-Server"
查看和管理节点
openclaw nodes status # 查看已连接节点openclaw devices list # 查看已配对设备openclaw devices approve <ID> # 批准配对请求
配置完成后,在 QQ 上说”去 Ubuntu 上看看磁盘”,AI 就会自动路由到 Ubuntu 执行命令。
七、安装与更新
安装
curl -fsSL https://openclaw.ai/install.sh | bash
更新
openclaw upgrade # 升级到最新版openclaw upgrade check # 检查是否有新版本
八、技能管理
技能(Skills)是 OpenClaw 的插件系统,可以从社区安装现成的,也可以自己写。
安装技能
clawhub search weather # 搜索技能clawhub install weather # 安装技能clawhub list # 查看已安装的技能clawhub update # 更新技能
九、快速参考速查表
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
写在最后
OpenClaw 的命令设计很清晰:分类 + 动作。所有命令都遵循 openclaw <类别> <动作> [参数] 的格式。
记不住也没关系,大部分时候你只需要跟它聊天,它在后台帮你执行。需要查命令时,openclaw --help 比搜索引擎快。
— END —
夜雨聆风