hermes - 💡(How to fix) Fix fix(cron): mark_job_run() auto-delete leaves orphaned output dirs when repeat limit is reached [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

`cron/jobs.py` lines 737–741:

if times is not None and times > 0 and completed >= times:
    jobs.pop(i)
    save_jobs(jobs)
    return  # ← OUTPUT_DIR / job_id left behind

`remove_job()` (lines 700–703) has the cleanup; `mark_job_run()` does not.

Fix Action

Fixed

Code Example

if times is not None and times > 0 and completed >= times:
    jobs.pop(i)
    save_jobs(jobs)
    return  # ← OUTPUT_DIR / job_id left behind
RAW_BUFFERClick to expand / collapse

Bug

`mark_job_run()` removes a job from `jobs.json` when its repeat limit is reached (lines 737–741 in `cron/jobs.py`), but does not delete `OUTPUT_DIR/<job_id>`. Each run of the job writes output files via `save_job_output()`, which creates `~/.hermes/cron/output/<job_id>/`. When the job auto-deletes on limit, that directory and all its `.md` files are left behind permanently.

`remove_job()` gained the same cleanup in PR #21882 (merged today). `mark_job_run()` is the only other path that deletes jobs and was not updated.

Steps to Reproduce

  1. Create a one-shot cron job: `repeat: 1`
  2. Let it run once — `save_job_output()` writes `~/.hermes/cron/output/<job_id>/`
  3. `mark_job_run()` hits the repeat limit, removes the job from `jobs.json`
  4. `~/.hermes/cron/output/<job_id>/` is never deleted

Expected

Output directory is removed when the job is auto-deleted, matching `remove_job()`.

Actual

Directory accumulates indefinitely after job completes.

Root Cause

`cron/jobs.py` lines 737–741:

if times is not None and times > 0 and completed >= times:
    jobs.pop(i)
    save_jobs(jobs)
    return  # ← OUTPUT_DIR / job_id left behind

`remove_job()` (lines 700–703) has the cleanup; `mark_job_run()` does not.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING