OpenClaw CLI命令参考
# OpenClaw CLI命令参考
OpenClaw提供了丰富的命令行工具,用于系统管理、任务执行和开发调试。本文档详细介绍了所有可用的CLI命令及其使用方法。
# 1. 基础命令
# 启动服务
openclaw start
1
启动OpenClaw服务进程。
# 停止服务
openclaw stop
1
停止正在运行的OpenClaw服务。
# 重启服务
openclaw restart
1
重启OpenClaw服务。
# 查看状态
openclaw status
1
显示当前服务状态和运行信息。
# 2. 任务管理命令
# 创建任务
openclaw task create [options]
1
选项:
--name <name>: 任务名称--type <type>: 任务类型--params <json>: 任务参数--priority <level>: 任务优先级 (low/normal/high)--timeout <seconds>: 超时时间
示例:
openclaw task create --name "数据处理" --type "data-process" --params '{"file":"data.csv"}'
1
# 查看任务
openclaw task show <task-id>
1
显示指定任务的详细信息。
# 列出任务
openclaw task list [options]
1
选项:
--status <status>: 按状态过滤 (pending/running/completed/failed)--agent <agent-id>: 按代理ID过滤--limit <count>: 限制返回数量
# 取消任务
openclaw task cancel <task-id>
1
取消指定的待处理任务。
# 删除任务
openclaw task delete <task-id>
1
永久删除指定任务记录。
# 3. 会话管理命令
# 创建会话
openclaw session create [options]
1
选项:
--agent <agent-id>: 指定代理ID--context <json>: 会话上下文--ttl <seconds>: 会话生存时间
# 列出会话
openclaw session list
1
# 会话对话
openclaw session chat <session-id> <message>
1
在指定会话中发送消息。
# 结束会话
openclaw session end <session-id>
1
结束指定会话。
# 4. 工具管理命令
# 列出工具
openclaw tool list
1
显示所有可用工具的列表。
# 工具信息
openclaw tool info <tool-name>
1
显示指定工具的详细信息。
# 执行工具
openclaw tool execute <tool-name> [options]
1
选项:
--params <json>: 工具参数--output <format>: 输出格式 (json/text)
示例:
openclaw tool execute file-processor --params '{"input":"/path/file.txt","operation":"compress"}'
1
# 5. 配置管理命令
# 查看配置
openclaw config show
1
显示当前系统配置。
# 设置配置
openclaw config set <key> <value>
1
设置配置项。
# 导出配置
openclaw config export [file-path]
1
导出配置到文件。
# 导入配置
openclaw config import <file-path>
1
从文件导入配置。
# 6. Cron任务命令
# 添加Cron任务
openclaw cron add [options]
1
选项:
--name <name>: 任务名称--cron <expression>: Cron表达式--session <type>: 会话类型 (main/isolated)--message <message>: 消息内容--announce: 启用通知--channel <channel>: 通知频道
# 列出Cron任务
openclaw cron list
1
# 运行Cron任务
openclaw cron run <job-id>
1
立即运行指定的Cron任务。
# 查看任务运行记录
openclaw cron runs <job-id>
1
查看指定任务的运行历史。
# 删除Cron任务
openclaw cron delete <job-id>
1
删除指定的Cron任务。
# 7. 日志管理命令
# 查看日志
openclaw log tail [options]
1
选项:
--lines <count>: 显示行数--follow: 实时跟踪日志--level <level>: 日志级别 (debug/info/warn/error)
# 日志搜索
openclaw log search <keyword>
1
在日志中搜索关键词。
# 清理日志
openclaw log cleanup
1
清理旧的日志文件。
# 8. 系统维护命令
# 系统健康检查
openclaw health check
1
执行系统健康检查。
# 系统更新
openclaw update [options]
1
选项:
--check: 检查更新--apply: 应用更新--force: 强制更新
# 系统备份
openclaw backup create [options]
1
选项:
--destination <path>: 备份目标路径--include-data: 包含数据备份--compress: 压缩备份文件
# 系统恢复
openclaw backup restore <backup-file>
1
从备份文件恢复系统。
# 9. 开发工具命令
# 代码格式化
openclaw format [files...]
1
格式化指定的代码文件。
# 代码检查
openclaw lint [files...]
1
检查代码质量问题。
# 运行测试
openclaw test [options]
1
选项:
--watch: 监听文件变化--coverage: 生成覆盖率报告--verbose: 详细输出
# 生成文档
openclaw docs generate
1
生成项目文档。
# 10. 帮助和信息命令
# 显示帮助
openclaw --help
1
显示所有可用命令的帮助信息。
# 显示版本
openclaw --version
1
显示OpenClaw版本信息。
# 命令别名
openclaw alias list
1
显示所有命令别名。
# 11. 配置文件
# 配置文件位置
- 全局配置:
~/.openclaw/config.json - 项目配置:
./openclaw.json - 环境配置:
~/.openclaw/env.json
# 配置文件示例
{
"server": {
"port": 3000,
"host": "localhost"
},
"database": {
"url": "postgresql://user:pass@localhost:5432/openclaw"
},
"logging": {
"level": "info",
"file": "/var/log/openclaw.log"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 12. 使用示例
# 创建并运行任务
# 创建任务
openclaw task create --name "文件处理" --type "file-process" --params '{"source":"/data/input.txt","target":"/data/output.txt"}'
# 查看任务状态
openclaw task show task_12345
# 等待任务完成
openclaw task show task_12345
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 设置Cron任务
# 每天凌晨2点执行备份
openclaw cron add --name "每日备份" --cron "0 2 * * *" --session main --system-event "执行每日备份"
1
2
2
# 系统维护
# 检查系统健康
openclaw health check
# 查看最新日志
openclaw log tail --lines 50 --level error
1
2
3
4
5
2
3
4
5
通过这些CLI命令,用户可以高效地管理OpenClaw系统,执行各种操作和任务,同时获得详细的系统信息和状态反馈。
上次更新: 3/18/2026