一键导入
cron-job-troubleshooting
Debug cron job execution failures — check job status, session logs, gateway errors, model availability, and stale gateway code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Debug cron job execution failures — check job status, session logs, gateway errors, model availability, and stale gateway code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Consolidate scattered utility scripts into a centralized directory with comprehensive documentation, then publish to version control.
Hermes gateway port 8642 is WebSocket-based only — NOT a REST API. Do NOT try to send WeChat/Weixin alerts via curl HTTP POST to the gateway. Understanding this prevents wasted time debugging "404 on all endpoints" when trying to send alerts from cron jobs.
Karpathy's LLM Wiki — build and maintain a persistent, interlinked markdown knowledge base. Ingest sources, query compiled knowledge, and lint for consistency.
A股每日/每周收盘行情汇总报告生成 — 东方财富 API 为主,AKShare (Sina + 同花顺) 兜底
每日美股收盘行情汇总 — 主要指数、板块轮动、个股亮点、宏观消息面、技术分析
每日A股收盘交易汇总报告生成流程 — 数据采集、资金流向分析、板块热点分析、技术面与消息面综合分析
| name | cron-job-troubleshooting |
| description | Debug cron job execution failures — check job status, session logs, gateway errors, model availability, and stale gateway code |
| category | devops |
| version | 1.2 |
When a cron job fails to execute, runs late, or produces unexpected results.
hermes cron list
# or programmatically:
cronjob(action='list')
Look for:
last_run_at: null → job never executedlast_status: error → job failedlast_delivery_error → delivery issuenext_run_at in the past → scheduler missed the triggerls -la ~/.hermes/sessions/ | grep cron_<job_id>
hermes logs 2>&1 | grep -E "cron|error|API call failed" | tail -30
Common errors:
API call failed after 3 retries. Connection error → model provider unavailablePermissionDeniedError: 403 → model not available in regionWebSocket error → platform connectivity issuetail -100 ~/.hermes/logs/gateway.error.log
Look for model/API errors, platform connection failures, idle timeouts.
Critical: Python processes load modules into memory at startup. If config.yaml provider was changed AFTER the gateway started, the running gateway still uses the OLD in-memory PROVIDER_REGISTRY. This causes Unknown provider errors even when the provider IS in the current on-disk code.
# Check when gateway process started
ps -p $(pgrep -f "hermes.*gateway") -o lstart=
# Check latest code commit date
cd ~/.hermes/hermes-agent && git log -1 --format="%ci"
# Compare: if gateway started BEFORE the provider was added to the codebase,
# it won't recognize it. The gateway loads whatever code version existed at startup.
Symptom: AuthError: Unknown provider 'X' when provider X IS in current auth.py PROVIDER_REGISTRY.
Fix: Restart the gateway so it loads the latest code:
# Option 1: Kill gateway, let watchdog auto-restart
kill $(pgrep -f "hermes.*gateway run")
# Option 2: Direct restart
hermes gateway restart
Prevention: Always restart the gateway after changing config.yaml provider or running hermes update.
Try a simple query with the same model used by the cron job. If it fails, the model provider is the root cause.
cronjob(action='run', job_id='<job_id>')
This forces immediate execution and updates last_run_at/last_status.
| Symptom | Likely Cause | Fix |
|---|---|---|
last_run_at: null | Model service down | Switch provider or wait |
| Session exists, no output | Skill error | Check skill, run manually |
| Late execution (>30min delay) | Model throttling | Retry later or switch model |
| Delivery error | Platform disconnected | Check platform config |
Unknown provider 'X' but X exists in code | Gateway running stale code | Restart gateway to reload modules |
Create a cron job that monitors other jobs and sends alerts on failure.
cronjob(
action='create',
name='系统健康检查',
schedule='0 */6 * * *', # Every 6 hours
deliver='weixin:USER_ID@im.wechat', # WeChat delivery
prompt='''执行定时任务监控检查:
1. 使用 cronjob(action='list') 获取所有定时任务的状态
2. 检查每个任务的 last_run_at 和 last_status
3. 如果发现以下情况,生成告警消息:
- last_status 不是 'ok'(任务失败)
- last_run_at 为空(任务从未运行)
4. 将告警消息格式化为清晰的中文报告
5. 如果有告警,使用 send_message 发送到微信
6. 告警格式:🚨 定时任务告警 - [问题描述]
如果没有异常,不发送消息。''',
skills=['cronjob']
)
Check your existing cron jobs for the deliver field format — it contains your WeChat user ID.
| Condition | Detection | Alert Message |
|---|---|---|
| Job failed | last_status != 'ok' | "任务 [name] 上次运行失败" |
| Never ran | last_run_at == null | "任务 [name] 从未运行过" |
deliver parameter for auto-delivery to messaging platformsdeliver='weixin:USER_ID@im.wechat'deliver='telegram:CHAT_ID'deliver must match the platform format exactlycronjob run only triggers execution; it doesn't guarantee success if the underlying issue (model availability) persistshermes update — new code on disk is not loaded by the running process~/.hermes/logs/gateway.error.log for detailed errors, not just hermes logsWEIXIN_HOME_CHANNEL configuration in .env