openclaw 基础篇(自动化与浏览器控制)

自动化
OpenClaw 结合 cron 调度与 heartbeat 心跳服务,完成自动化任务运行。
启用 Cron
{cron: { # 配置项:定时任务enabled: true, # 开关:开启(true=开启,false=关闭)maxConcurrentRuns: 2, # 最大同时运行数:2个},}
常用命令
# 新增任务(每天 9 点)openclaw cron add --schedule "0 9 * * *" \--message "总结昨天的邮件并发到 Telegram" \--channel telegram --target <你的ChatID># 查看任务openclaw cron list# 删除任务openclaw cron remove <cron-id>
Heartbeat(周期检查)
{agents: { // 配置:所有智能代理(AI 机器人/自动化助手)defaults: { // 默认配置(所有代理统一用这个规则)heartbeat: { // 心跳配置(代理定期“报平安”的机制)every: "30m", // 每 30 分钟发送一次心跳target: "last", // 心跳目标:最新/最后一个任务/实例model: "qwen/qwen3.5-9b", // 使用的 AI 模型:qwen3.5-9b模型 },},},}
在工作空间写 HEARTBEAT.md,定义检查清单(邮箱、日历、通知等),减少重复配置。
何时用 Cron,何时用 Heartbeat
要求在指定精确时间点触发执行:用 cron
批量完成上下文检测,实现高效复用:用 heartbeat
浏览器控制
OpenClaw 支持两种浏览器模式:
-
openclaw 托管浏览器(自动化任务)
-
chrome 扩展接管(使用你现有登录态)
基础配置
{browser: {enabled: true,defaultProfile: "openclaw",profiles: {openclaw: { cdpPort: 18800, color: "#FF4500" },},},}
CLI 常用命令
openclaw browser --browser-profile openclaw statusopenclaw browser --browser-profile openclaw startopenclaw browser --browser-profile openclaw open https://example.comopenclaw browser --browser-profile openclaw screenshotopenclaw browser --browser-profile openclaw snapshot
Chrome Extension 使用流程
安装 OpenClaw Browser Relay 扩展。
-
打开目标网页,点击扩展图标,使 Badge 显示 ON。
-
在聊天中直接让 Agent 执行点击、输入、读取等任务。
夜雨聆风