Compatible with Claude Code, Codex CLI, Cursor, Windsurf, and any SKILL.md-compatible agent.
Cron Doctor
Diagnose and triage cron job failures.
Usage
When asked to check cron health or diagnose failures:
1. List All Jobs
CODEBLOCK0
2. Check Recent Execution
CODEBLOCK1
3. Identify Problems
Error patterns to watch:
- -
"command not found" — Missing executable or PATH issue - INLINECODE1 — File/directory permissions wrong
- INLINECODE2 — Script path incorrect
- INLINECODE3 — Job took too long
- INLINECODE4 — Network/service down
- INLINECODE5 — API throttling
- Missing output — Job may not be running at all
4. Triage Priority
| Priority | Criteria |
|---|
| 🔴 Critical | Trading, backup, security jobs |
| 🟠 High |
User-facing deliveries |
| 🟡 Medium | Monitoring, research jobs |
| 🟢 Low | Nice-to-have, non-essential |
5. Generate Report
Write to ~/workspace/reports/cron-health-YYYY-MM-DD.md:
CODEBLOCK2
6. Common Fixes
| Error | Fix |
|---|
| Command not found | Use full path to executable, or set PATH in crontab |
| Permission denied |
Check file permissions, run
chmod +x script.sh |
| No output | Add
>> /tmp/job.log 2>&1 to capture output |
| Wrong timezone | Set
TZ= in crontab or use system timezone |
| Rate limit | Reduce frequency or add backoff |
7. Debugging Tips
CODEBLOCK3
Escalation
If 3+ critical jobs failed, alert the user immediately.
Verification Gates
Before claiming diagnosis complete:
- - [ ] All failed jobs listed — none skipped or ignored
- [ ] Priority assigned — based on impact, not just recency
- [ ] Fix suggested — actionable next step for each failure
- [ ] Report written — to INLINECODE10
- [ ] Critical failures escalated — 3+ critical = alert user
技能名称: cron-doctor
详细描述:
兼容 Claude Code、Codex CLI、Cursor、Windsurf 以及任何兼容 SKILL.md 的代理。
Cron Doctor
诊断并分类处理 cron 任务故障。
使用方法
当被要求检查 cron 健康状况或诊断故障时:
1. 列出所有任务
bash
列出用户的 crontab
crontab -l
列出系统 crontab
sudo cat /etc/crontab
ls -la /etc/cron.d/
2. 检查最近执行情况
bash
检查 cron 日志(位置因系统而异)
Debian/Ubuntu:
grep CRON /var/log/syslog | tail -50
RHEL/CentOS:
tail -50 /var/log/cron
macOS:
log show --predicate process == cron --last 1h
检查特定任务输出
grep your
jobname /var/log/syslog | tail -20
3. 识别问题
需要关注的错误模式:
- - command not found — 缺少可执行文件或 PATH 问题
- Permission denied — 文件/目录权限错误
- No such file or directory — 脚本路径不正确
- timeout — 任务执行时间过长
- ECONNREFUSED — 网络/服务宕机
- rate limit — API 限流
- 缺少输出 — 任务可能根本没有运行
4. 分类优先级
面向用户的交付任务 |
| 🟡 中 | 监控、研究任务 |
| 🟢 低 | 锦上添花、非必需任务 |
5. 生成报告
写入 ~/workspace/reports/cron-health-YYYY-MM-DD.md:
markdown
Cron 健康报告 - [日期]
摘要
- - ✅ 健康:X 个任务
- ⚠️ 警告:X 个任务
- ❌ 失败:X 个任务
失败的任务
[任务名称]
- - 错误: [消息]
- 上次成功: [日期]
- 优先级: [级别]
- 修复: [建议操作]
建议
- 1. [行动项]
- [行动项]
6. 常见修复方法
| 错误 | 修复方法 |
|---|
| 找不到命令 | 使用可执行文件的完整路径,或在 crontab 中设置 PATH |
| 权限被拒绝 |
检查文件权限,运行 chmod +x script.sh |
| 无输出 | 添加 >> /tmp/job.log 2>&1 以捕获输出 |
| 时区错误 | 在 crontab 中设置 TZ= 或使用系统时区 |
| 限流 | 降低频率或添加退避策略 |
7. 调试技巧
bash
测试 cron 环境(cron 的 PATH 最小化)
env -i /bin/sh -c echo $PATH
验证脚本手动运行
/path/to/your/script.sh
检查 cron 守护进程是否在运行
systemctl status cron # Linux
launchctl list | grep cron # macOS
升级处理
如果 3 个或以上严重任务失败,立即提醒用户。
验证关卡
在声称诊断完成之前:
- - [ ] 所有失败任务均已列出 — 无遗漏或忽略
- [ ] 已分配优先级 — 基于影响,而非仅基于最近发生时间
- [ ] 已建议修复方法 — 针对每个失败的可操作下一步
- [ ] 报告已写入 — 至 ~/workspace/reports/cron-health-YYYY-MM-DD.md
- [ ] 严重故障已升级 — 3 个或以上严重 = 提醒用户