OpenClaw 常用命令指南 安装与初始化安装# 方式一一键安装脚本推荐curl -fsSLhttps://openclaw.ai/install.sh | bash# 方式二npm全局安装npm install -g openclaw# 方式三Dockerdocker pull openclaw/openclaw:latestdocker run -d --name openclaw -v ~/.openclaw:/root/.openclawopenclaw/openclaw:latest初始化# 交互式初始化向导openclaw onboard# 快速配置向导openclaw configure# 验证安装openclaw --versionopenclaw --help# 查看全局帮助openclaw help # 顶级命令列表openclaw helpgateway # gateway 子命令帮助openclaw helpcron # cron 子命令帮助openclaw helpagents # agents 子命令帮助Gateway网关管理Gateway 是 OpenClaw 的核心后端 WebSocket 服务默认ws://127.0.0.1:18789所有消息、技能调用、渠道路由均经过 Gateway。启停控制openclaw gateway start # 启动网关openclaw gateway stop # 停止网关openclaw gateway restart # 重启网关配置修改后必须执行openclaw gateway status # 查看网关状态运行模式# 前台运行默认openclaw gateway run# 自定义端口 详细日志openclaw gateway--port 18789 --verbose# 绑定模式openclaw gateway--bind loopback # 仅本地访问最安全推荐openclaw gateway--bind lan # 局域网访问openclaw gateway--bind tailnet # Tailscale 网络访问# 认证模式openclaw gateway--auth token --token t #Token 认证openclaw gateway--auth password --password p #密码认证# 开发模式openclaw gateway--dev# 强制启动杀掉占用端口的进程openclaw gateway--force# 日志选项openclaw gateway--ws-log compact # 紧凑WebSocket 日志openclaw gateway--raw-stream # 记录原始模型流事件到 jsonl系统服务openclaw gateway install # 安装为系统服务开机自启openclaw gateway uninstall # 移除系统服务openclaw gateway install --port 18789 --token t --force健康检查与诊断openclaw gateway health # 网关健康检查openclaw gateway health --json # JSON 格式输出openclaw gateway health --verbose # 详细信息openclaw gateway probe # 可达性 发现 健康 状态openclaw gateway discover # 通过Bonjour 发现网关 openclaw gatewaystatus --no-probe # 跳过实时RPC 探测openclaw gateway status --json # 机器可读格式高级操作openclaw gateway call method --params json # 直接 RPC 方法调用openclaw gateway usage-cost # 费用摘要最近30 天openclaw gateway usage-cost --days 7 # 最近7 天Tailscale暴露openclaw gateway--tailscale serve # Tailscale Serve暴露openclaw gateway--tailscale funnel # TailscaleFunnel 暴露公网Agent管理Agent是智能实体——每个 Agent 拥有独立的模型、工作区和绑定渠道查看Agentopenclaw agents list # 列出所有Agentopenclaw agents list --json # JSON 格式openclaw agents list --bindings # 显示每个Agent 的渠道绑定创建 Agent# 交互式创建推荐openclaw agents addopenclaw agents add[name]# 非交互式创建自动化部署openclaw agents addmy-agent \--workspace ~/.openclaw/workspace-my-agent \--model anthropic/claude-sonnet-4-5 \--bind whatsapp:personal \--non-interactive渠道绑定管理一个 Agent 可绑定多个渠道一个渠道可被多个 Agent 共享。openclaw agents bindings # 所有绑定关系openclaw agents bindings --agent id # 指定 Agent 的绑定openclaw agents bind --agent id --bind channel[:accountId] # 添加绑定openclaw agents unbind --agent id --bind channel[:accountId] # 移除绑定openclaw agents unbind --agent id --all # 移除所有绑定手动运行Agent# 发送消息openclaw agent--message Hello --to dest# 指定会话openclaw agent--message Hello --session-id id# 思考级别openclaw agent--message Hello --thinking high# 绕过网关本地直接运行openclaw agent--message Hello --local# 发送并投递到渠道openclaw agent--message Hello --channel whatsapp --deliver# JSON 输出openclaw agent--message Hello --json删除Agentopenclaw agents delete id # 删除Agentopenclaw agents delete id --force # 强制删除跳过确认会话管理openclaw sessions # 列出已存储的对话会话Cron定时任务在指定时间执行任务——早晨简报、定时提醒、数据检查等。查看任务openclaw cron list # 查看所有定时任务openclaw cron list--agent ops # 按Agent 筛选openclaw cron list--json # JSON 输出含status 字段openclaw cron status # 任务执行状态概览openclaw cron showjob-id # 人类可读视图 投递路由预览openclaw cron get job-id # 原始存储JSON状态字段含义创建任务# Cron 表达式5字段或6字段 可选 --tzopenclaw cron add--name Morning Briefing \--cron 0 8 * * * \--message Todays weather andschedule \--channel telegram:chat:123# 固定间隔openclaw cron add--name Check Status \--every 10m \--message Check service health# 一次性/延迟任务ISO8601 或相对时间openclaw cron add--name Reminder \--at 20m \--message Remind me in 20 minutes# 快速创建别名create addopenclaw croncreate 0 7 * * * Summarize overnight updates. \--name Morning brief --agent ops# 带时区openclaw cron add--name NYC report \--cron 0 9 * * 1-5 --tz America/New_York \--message Workday summary会话类型openclaw cron edit job-id --session isolatedopenclaw cron edit job-id --session session:daily-brief投递模式# 投递到Telegram 论坛话题openclaw cron editjob-id --announce --channel telegram \--to -1001234567890 --thread-id 42# 投递到Slackopenclaw cron edit job-id --announce --channel slack \--to channel:C1234567890# Webhook 投递openclaw croncreate 0 18 * * 1-5 Summarize todays deploys as JSON.\--name Deploy digest --webhookhttps://hooks.example.com/openclaw/cron# 禁用投递openclaw cron edit job-id --no-deliverShell命令任务# 基础Shell 任务openclaw croncreate */15 * * * * \--name Queue depth probe \--command scripts/check-queue.sh\--command-cwd /srv/app \--announce --channel telegram --to-1001234567890# 精确argv不经过 shell 解析openclaw croncreate */30 * * * * \--name Position export \--command-argv[node,scripts/export-position.mjs] \--command-cwd /srv/app \--command-env NODE_ENVproduction\--command-input{mode:summary} \--timeout-seconds 120 \--no-output-timeout-seconds 30 \--output-max-bytes 65536 \--webhookhttps://hooks.example.com/openclaw/cron任务生命周期openclaw cron editid # 编辑任务openclaw cron rmid # 删除任务openclaw cronenable id # 启用openclaw crondisable id # 禁用openclaw cron runid # 手动触发默认强制运行openclaw cron runid --due # 仅当前到期时运行openclaw cron runid --wait --wait-timeout 10m --poll-interval 2s # 阻塞等待完成openclaw cronruns # 查看执行历史openclaw cron runs--id id --limit 50openclaw cron runs--id id --run-id run-id # 检查特定运行模型与上下文选项openclaw cron editid --model anthropic/claude-sonnet-4-5 # 模型覆盖openclaw cron editid --clear-model # 移除单任务模型openclaw cron editid --thinking high # 思考级别覆盖openclaw cron editid --light-context # 跳过工作区引导注入openclaw cron editid --tools exec,read # 限制可用工具openclaw cron editid --agent ops # 固定到指定 Agentopenclaw cron editid --clear-agent # 恢复默认 Agent配置管理配置文件路径~/.openclaw/openclaw.json格式JSON5支持//注释和尾随逗号配置读写openclaw config getpath # 获取配置值openclaw config setpath value # 设置配置值openclaw configunset path # 删除配置项openclaw configfile # 打印配置文件路径openclaw config validate # 验证配置schemaopenclaw config validate --json # JSON 格式验证结果openclaw config set path value --dry-run # 干运行不写入磁盘openclaw config patch # JSON mergepatch 方式部分更新