装完 OpenClaw 第一次想跑命令,你大概会翻 5 分钟文档才下手——gateway start 在哪个子菜单?onboard 跟 configure 到底差在哪?这篇就把那 5 分钟省下来:12 个子命令按场景收齐,逐字照搬、Ctrl+F 可查。命令全部沿用官方手册,章节顺序按”装完之后”的路径走,从启动 Gateway 到接飞书机器人,再到日常排错。
一、Gateway:先让后台进程跑起来
Gateway 是 OpenClaw 的中枢——它没起来,下面所有模型、频道、智能体都只是配置。装完之后第一件事就是让它常驻后台,下面这组命令覆盖 90% 的日常运维。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openclaw gateway run –force
|
|
|
openclaw gateway –port 18789
|
|
|
|
|
|
openclaw gateway uninstall
|
|
|
|
|
|
|
💡 gateway install 装的是 systemd / launchd,开机自启,不是 nohup &。
二、首次配置:跟着向导走,还是手改 YAML
OpenClaw 的配置落在 ~/.openclaw 下面,新手跟着向导跑最稳;想批量改、塞进 CI 或者调参测试,那就直接敲 config set。下面这组是配过的都说好用。
openclaw config set gateway.port 18789openclaw config set agents.main.model "minimax/MiniMax-M3"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openclaw setup && openclaw gateway install && openclaw gateway start
|
openclaw config get all # 全部配置openclaw config get gateway # 网关配置openclaw config get agents # 智能体配置openclaw config file # 查看配置文件路径openclaw config validate # 验证配置是否合法
openclaw config unset gateway.port # 取消单个配置openclaw config reset # 重置所有配置
openclaw setup # 初始化配置和 workspaceopenclaw onboard # 引导式配置模型和频道openclaw models probe # 确认模型连通openclaw gateway install # 安装开机自启openclaw gateway start # 启动 Gatewayopenclaw logs --follow # 跟踪日志确认运行正常
三、模型管理:探活、切换、别名管理
模型列表跟实际可用不一定对得上——配置里写的不一定还活着,活着的不一定响应快。这一组命令专门用来摸清底细、临时切换、给模型起小名。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openclaw models set default “minimax/MiniMax-M2.7”
|
|
|
openclaw models set-image “doubao-seedream-4-0-250828”
|
|
|
|
|
|
|
|
|
openclaw models fallbacks
|
💡 models probe 会真发请求测延迟,别在生产高峰期跑——容易把限速配额打空。
四、频道登录:把机器人挂到飞书 / TG / 企微
频道的 login 走的是扫码流程,跟你手动打开客户端没区别。装完一个频道顺手 status --probe 探一下,别等消息丢了才回头查。
|
|
|
|
|
|
|
|
|
|
|
openclaw channels status –probe
|
|
|
|
|
|
openclaw channels login telegram
|
|
|
openclaw channels login whatsapp
|
|
|
openclaw channels login discord
|
|
|
openclaw channels logout telegram
|
|
|
openclaw channels logout all
|
|
|
openclaw channels add –channel feishu –token ***
|
|
|
openclaw channels resolve –channel feishu –name 张三
|
openclaw channels login feishu # 扫码登录openclaw channels status # 确认连接状态openclaw message send --channel feishu --target @VV --message "连接测试"
💡 飞书 / 企微的 token 在各自管理后台申请,--token *** 占位别照抄——明文塞聊天窗口会泄。
五、扩展生态:插件和 Skills 装法不同
插件是给 OpenClaw 加新能力(接入新聊天平台、新工具),Skills 是给模型加技能(写代码、查天气、读 PDF)。两者各管一摊,别混。
|
|
|
|
|
|
|
|
openclaw plugins install <包名或路径>
|
|
|
openclaw plugins uninstall <插件名>
|
|
|
openclaw plugins enable <插件名>
|
|
|
openclaw plugins disable <插件名>
|
|
|
|
|
|
openclaw plugins info <插件名>
|
|
|
|
|
|
|
|
|
|
|
|
openclaw skills info <技能名>
|
|
|
|
💡 插件装完默认禁用,还得 enable 才生效;Skills 装好直接能用,不用手动开。
六、定时任务:cron 表达式别手写
OpenClaw 的 cron 用标准 5 位表达式(分 时 日 月 周),配置里塞长字符串容易出错,所以 --name 跟 --cron 分开传。runs 跟 status 是排查”定时任务怎么没跑”的两件套。
|
|
|
|
|
|
|
|
openclaw cron add –name “每日新闻” –cron “0 8 *” –message “你好” –channel feishu
|
|
|
|
|
|
|
|
|
|
|
|
openclaw cron disable <任务ID>
|
|
|
openclaw cron enable <任务ID>
|
|
|
openclaw cron edit <任务ID>
|
|
|
|
七、消息收发:发、读、互动、群管一站齐
这一组是平时用得最频繁的——发公告、读历史、加 reaction、踢人,全在 openclaw message 这棵子树下面。发跟读拆成两张表,互动的几个动作(react / pin / delete)单独收,群管理(timeout / kick / ban)再单独收。
|
|
|
|
|
openclaw message send –target @用户名 –message “内容”
|
|
|
openclaw message send –channel feishu –target @VV –message “内容”
|
|
|
openclaw message send –target @VV –media image.png
|
|
|
openclaw message poll –channel discord –target channel:123 –poll-question “吃什么?” –poll-option Pizza –poll-option Sushi
|
|
|
|
|
|
openclaw message read –channel feishu –limit 20
|
|
|
openclaw message search –channel feishu –query “关键词”
|
|
|
|
|
|
openclaw message react –channel feishu –message-id –emoji “👍”
|
|
|
openclaw message pin/unpin –channel feishu –message-id
|
|
|
openclaw message delete –channel feishu –message-id
|
|
|
|
|
|
openclaw message timeout –channel feishu –target @张三 –minutes 10
|
|
|
openclaw message kick –channel feishu –target @张三
|
|
|
openclaw message ban –channel feishu –target @张三
|
💡 --message-id 是消息唯一 ID(不是消息文本),先 message read 拿到再操作,粘错就发给别人了。
八、日志与排错:出问题先开 –follow
OpenClaw 的报错都带时间戳和模块名,--follow 实时跟、--error 只看错、--json 喂给日志平台(ELK / Loki),三个开关自由组合。下面这三行是出问题时跑得最多的”救援三件套”。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openclaw logs –local-time
|
openclaw gateway run --verbose # 前台运行看报错openclaw logs --error # 查看错误日志openclaw doctor --fix # 自动修复
💡 --local-time 默认是 UTC(看着像差 8 小时),加了这个开关才显示本地时区。
九、doctor:OpenClaw 自带的”体检中心”
跟人看医生一样,先 doctor 跑一遍体检,再决定是 --fix 让它自己修还是手改配置。--generate-gateway-token 跟 --scan 是救火时常用的两个开关。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openclaw doctor –generate-gateway-token
|
|
|
|
十、浏览器自动化:ref 编号要会看
OpenClaw 启动一个无头 Chromium 帮你点网页,命令里那些数字(11、12、13)是 ref 编号——screenshot 之后从图里挑元素的索引,跟 Selenium 的 element ref 是同一种思路。--fn 那条是注入 JS。
|
|
|
|
|
|
|
|
|
|
|
openclaw browser navigate https://test.com
|
|
|
openclaw browser screenshot
|
|
|
openclaw browser type 11 “内容”
|
|
|
openclaw browser click 12
|
|
|
openclaw browser click 13 –submit
|
|
|
openclaw browser press Enter
|
|
|
openclaw browser wait –text “完成”
|
|
|
openclaw browser dialog –accept
|
|
|
openclaw browser resize 1280 760
|
|
|
|
|
|
openclaw browser console –level error
|
|
|
openclaw browser evaluate –fn ‘(el) => el.textContent’ –ref 7
|
十一、智能体与会话:多 bot 怎么共存
OpenClaw 支持同时挂多个智能体(不同人格、不同模型),通过 bindings 把它们路由到不同频道;会话是某个智能体跟某个用户的聊天记录,--all-agents 能聚合看。
|
|
|
|
|
|
|
|
openclaw agents add <智能体名>
|
|
|
openclaw agents delete <智能体名>
|
|
|
openclaw agents set-identity –name 虾哥 –emoji 🦐
|
|
|
openclaw agents bind <智能体名> –channel feishu
|
|
|
|
|
|
openclaw agents unbind <智能体名> –channel feishu
|
|
|
|
|
|
|
|
|
openclaw sessions –agent main
|
|
|
openclaw sessions –active 120
|
|
|
openclaw sessions –all-agents
|
|
|
|
|
|
openclaw sessions cleanup
|
💡 路由冲突的时候 bindings 列出来一眼能看出哪条规则吃掉了请求,比翻配置 YAML 快得多。
十二、实战:组合命令直接抄
把上面几节的命令串起来能解决 90% 的日常场景——这一组是踩过坑才留下来的”标准答案”,遇到不熟的子命令,--help 是最快的查法,别去翻那 30 页文档。
openclaw gateway --helpopenclaw models --helpopenclaw channels --help
💡 openclaw xxx --help 看一眼输出的 USAGE 段,比 Google 搜索快一截——子命令带子命令的二级 help 也照样能查。