CronWatch

July 31, 2026 · View on GitHub

English | 中文

GitHub stars GitHub forks GitHub license Release CI Tests Last commit

Cron 任务失败总是悄悄发生?CronWatch 让每个定时任务失败可知、原因可查、异常可警。 轻量、零配置、安装即用,支持 Hermes / Claude Code / OpenCode / Codex 和任意 CLI 命令——无需额外监控任务,不增加轮询负担。

任务失败 → 秒级告警(飞书/钉钉/企业微信/任意 Webhook)
任务变慢 → 自适应基线检测,超常即报
失败原因 → 内置 10 类错误诊断,附修复建议

Why / 为什么用

Scheduled job failures (execution error or delivery error) are usually silent — no notification, discovered days later. The traditional fix — a separate "health-check cron job" that polls job status — is fragile: the monitor itself can fail, detection lags behind the check interval, and it adds another scheduling layer.

CronWatch hooks the post-run choke points of the job lifecycle, so failures are detected the moment they happen.

快速开始 / Quick Start

# 方式一:GitHub Release 安装(推荐)
pip install https://github.com/nicokickcpython/cronwatch/releases/download/v1.0.0/cron_ops-1.0.0-py3-none-any.whl
cron-ops-wrap "daily-backup" -- /path/to/backup.sh

# 方式二:Hermes 插件
hermes plugins install nicokickcpython/cronwatch/cron-health-hook

# 方式三:无依赖 wrapper(零安装,直接下载脚本)
curl -sL https://raw.githubusercontent.com/nicokickcpython/cronwatch/main/cli/cron-ops-wrap.sh -o cron-ops-wrap.sh
chmod +x cron-ops-wrap.sh
./cron-ops-wrap.sh "daily-backup" -- /path/to/backup.sh

系统 crontab 用法:

0 2 * * * cron-ops-wrap "daily-backup" -- /path/to/backup.sh
0 3 * * * cron-ops-wrap "code-review" -- claude -p "review the repo"
0 4 * * * cron-ops-wrap "data-job" -- opencode run "process today's data"

Components / 组件

ComponentAnswersIntegrationStatus
cron-health-hookDid the job fail?Hermes plugin
cron-latency-watchIs the job getting slow?Hermes plugin
cron-error-analyzerWhy did it fail? How to fix?Hermes plugin
cron-ops CLIcheck / diagnose / alertall agents
cron-ops-wrapuniversal command wrapperClaude Code/OpenCode/Codex/any
cron-dupe-detectorWas the job fired twice?Hermes plugin🚧

CLI Usage / CLI 用法

# diagnose an error string / 诊断错误
cron-ops analyze "429 Too Many Requests"
# → diagnosis: API rate limit / quota exhausted

# check one job status file / 检查任务状态
cron-ops check /path/to/status.json

# check all status files / 批量检查
cron-ops check-all ~/.cron-ops/status/

Alert Configuration / 告警配置

VarDescriptionDefault
CRON_ALERT_CHAT_IDFeishu chat_id for alertsFEISHU_HOME_CHANNEL
CRON_ALERT_WEBHOOKGeneric webhook URL (DingTalk/WeCom/Slack...)none
CRON_ALERT_COOLDOWNCooldown between same-failure alerts (s)3600
CRON_LATENCY_FACTORAlert when duration > factor × rolling avg3.0
CRON_LATENCY_CEILINGAbsolute ceiling seconds3600
CRON_DUPE_WINDOWDuplicate-fire window (s)120
CRON_OPS_STATUS_DIRStatus file dir for wrapper~/.cron-ops/status/

Diagnosis Knowledge Base / 诊断知识库

Error signatureDiagnosis
429 / rate limitAPI rate limited
timeoutnetwork/API timeout
99992402 field validationFeishu msg validation failed
access denied / 99991672missing permission scope
401 / invalid_api_keyAPI key invalid
context length / tokencontext/token exceeded
script not foundscript path wrong
empty responsemodel empty response
ImportErrormissing dependency
OOM / killedout of memory

Roadmap

  • Hermes plugins ×3 (health-hook / latency-watch / error-analyzer)
  • Universal CLI (check / check-all / analyze)
  • Universal wrapper
  • GitHub Release distribution (wheel + sdist)
  • 20 automated test cases
  • cron-dupe-detector
  • Daily execution digest
  • Claude Code hooks native adapter
  • OpenCode plugin native adapter

License

MIT