--- name: hermes-cron-management description: Diagnose, consolidate, and fix Hermes cron jobs across profiles. Covers the gateway dependency, stuck-job detection, cross-profile migration, and direct jobs.json editing when the cronjob tool can't reach other profiles. version: 1.1.0 author: Hermes Agent platforms: [linux] --- # Hermes Cron Management Diagnose and fix Hermes cron jobs — especially when jobs are stuck because their profile has no running gateway. ## When to Use - Cron jobs have `next_run_at` timestamps in the past - Jobs were created in a profile that no longer has a gateway running - Consolidating scattered cron jobs into a single profile with a reliable gateway - Validating that all cron jobs across all profiles are progressing properly ## Core Rule: Gateway Dependency **Hermes cron jobs only execute when a gateway process is running for that profile.** A job defined in `~/.hermes/profiles//cron/jobs.json` will never fire unless a gateway process is active for ``. The `hermes.service` systemd unit or a `hermes gateway run --profile ` process must be running. This is the #1 cause of stuck cron jobs. Before debugging anything else, check: is a gateway running for this profile? ## Diagnosis Workflow ### 1. List all profiles and their cron jobs ```bash for p in $(ls ~/.hermes/profiles/); do f="$HOME/.hermes/profiles/$p/cron/jobs.json" [ -f "$f" ] && echo "=== $p ===" && python3 -c " import json with open('$f') as fh: data = json.load(fh) for j in data.get('jobs', []): print(f' {j[\"id\"][:12]} {j[\"name\"]} enabled={j[\"enabled\"]} state={j[\"state\"]} next={j.get(\"next_run_at\",\"?\")} last_status={j.get(\"last_status\",\"?\")}') " done ``` ### 2. Check which profiles have running gateways ```bash ps aux | grep 'hermes.*gateway run' | grep -v grep ``` ### 3. Cross-reference Any profile with cron jobs but NO gateway process → those jobs are stuck. Their `next_run_at` will be frozen in the past. ## Fix: Consolidate into a Profile with a Running Gateway The reliable fix: move orphaned jobs into a profile that has a running gateway. ### Step 1: Verify the target profile ```bash # Confirm gateway is running ps aux | grep 'hermes.*gateway.*general' | grep -v grep # Confirm cron scheduler is active in gateway logs grep 'cron\|tick' ~/.hermes/profiles/general/logs/gateway.log | tail -5 # Confirm required models are available curl -s localhost:11434/api/tags | python3 -c "import sys,json; [print(m['name']) for m in json.load(sys.stdin).get('models',[])]" ``` ### Step 2: Verify dependencies exist in target profile Before migrating, confirm the target profile has: - Required skills (check `~/.hermes/profiles//skills/`) - Required scripts (check `~/.hermes/profiles//scripts/`) - Workdir paths exist on disk ### Step 3: Create the job in the target profile Use `cronjob(action='create', ...)` from within the target profile's session. Match the original job's schedule, model, provider, skills, toolsets, workdir, and deliver settings. **For no_agent script jobs:** The `cronjob` tool requires scripts to be in `~/.hermes/scripts/` relative to the profile. Copy the script from the source profile first: ```bash cp ~/.hermes/profiles//scripts/