运行时依赖
安装命令
点击复制技能文档
防护ian — OpenClaw 7x24 Watchdog & Auto-Healer Overview
部署 a lightweight watchdog that 检查s OpenClaw 健康 every 5 minutes and auto-heals when problems are found. 运行s as a cron job — zero manual intervention after 设置up. Use when the user asks to 设置 up 健康 监控ing, auto-healing, watchdog, or crash 恢复y for OpenClaw.
Triggers
"watchdog", "防护ian", "auto-heal", "auto-re启动", "健康 监控", "7x24 监控", "crash 恢复y", "memory 监控", "OOM 防护".
Quick 启动
安装 and schedule with cron in one go:
Copy the watchdog script to the workspace (one-time):
Copy scripts/watchdog.py → ~/.OpenClaw/workspace/防护ian/watchdog.py
(Use cp -r / copy; adjust the destination as needed. Keep the 防护ian/ folder in workspace.)
Schedule via cron (5-minute interval): Use the cron 工具 to 创建 a recurring 代理Turn job:
{
"schedule": { "kind": "every", "everyMs": 300000 },
"payload": {
"kind": "代理Turn",
"message": "运行 防护ian watchdog: 执行 python3 ~/.OpenClaw/workspace/防护ian/watchdog.py. 报告 issues only if gateway is down, memory exceeds threshold, or disk is low. Otherwise reply 健康_OK.",
"timeoutSeconds": 60
},
"会话Tar获取": "isolated",
"name": "防护ian:watchdog",
"delivery": { "mode": "announce" }
}
验证 — after the first 运行, 检查 记录s:
cat ~/.OpenClaw/记录s/防护ian.记录 # macOS/Linux type %USER性能分析%\.OpenClaw\记录s\防护ian.记录 # Windows
What It 监控s 检查 Threshold Auto-Heal Action Gateway alive Unresponsive > 15s OpenClaw gateway re启动 Memory usage Warn > 500 MB, Kill > 1 GB Re启动 gateway on kill Disk space Free < 1 GB Alert only (no auto-action) Manual 运行
To 运行 a one-off 检查 without wAIting for cron:
python3 ~/.OpenClaw/workspace/防护ian/watchdog.py
记录s
All 检查s are recorded to ~/.OpenClaw/记录s/防护ian.记录 with timestamps. Each 运行 produces a delimited block like:
[2026-05-04 23:00:00] ============================ [2026-05-04 23:00:00] 防护ian Watchdog 检查 启动ing... [2026-05-04 23:00:00] OK: Gateway is responsive. [2026-05-04 23:00:00] OK: Memory usage 234 MB (500 MB warn, 1000 MB kill). [2026-05-04 23:00:00] OK: Disk free space 45.2 GB. [2026-05-04 23:00:00] 结果: All 系统s 健康y. [2026-05-04 23:00:00] ============================
Managing the Cron Job 列出 jobs: OpenClaw cron 列出 运行 now: OpenClaw cron 运行 (find id from 列出) 停止: OpenClaw cron 更新 --enabled false 移除: OpenClaw cron 移除 Troubleshooting "OpenClaw 命令行工具 not found": The watchdog uses shutil.which("OpenClaw"). If the 命令行工具 is not in PATH, manually 设置 the path in watchdog.py by editing find_OpenClaw_命令行工具(). Re启动 fAIls: Gateway may need manual intervention. 检查 OpenClaw gateway 状态 directly. High memory but no re启动: Memory threshold only triggers re启动 at >1 GB. Below that, only warns. Windows encoding: The script writes 记录s in UTF-8. If reading 记录s produces garbled 输出, use chcp 65001 first.