Skip to content

fix(cron): add standalone cron daemon mode - #41363

Closed
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone-clean
Closed

fix(cron): add standalone cron daemon mode#41363
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone-clean

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds hermes cron daemon command to run the cron scheduler as a standalone process, independent of the gateway.

Problem: Cron jobs don't execute on systems where the gateway isn't running (Windows without service installation, headless servers, etc.). The cron scheduler only runs inside the gateway process, so if the gateway isn't started, cron jobs never fire.

Solution: New hermes cron daemon command that runs the same tick loop as the gateway's internal cron ticker, but as a standalone process.

Changes Made

  • hermes_cli/cron.py: Added cron_daemon() function that runs the cron tick loop with signal handling
  • hermes_cli/main.py: Added daemon subcommand parser with --interval option (default 60s)

How to Test

  1. Create a cron job:

    hermes cron create "* * * * *" "Test job - just print hello" --name test-daemon
    
  2. Start the cron daemon:

    hermes cron daemon --interval 60
    
  3. Verify the job executes (check hermes cron list for last_run_at)

  4. Stop with Ctrl+C

Related Issue

Fixes #41037 (Cron jobs never execute: last_run_at always null after manual trigger)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (standalone cron daemon mode)

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've tested on my platform: Android/Termux

@alt-glitch alt-glitch added type/feature New feature or request comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists labels Jun 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Same standalone-cron-daemon fix as the recently-closed #41167 (identical hermes_cli/cron.py + main.py 'hermes cron daemon --interval' approach for #41037). Flagging as duplicate for maintainer consolidation.

@alaamohanad169-ship-it
alaamohanad169-ship-it force-pushed the fix/cron-daemon-standalone-clean branch from 825e781 to f75a10d Compare June 8, 2026 13:51
@alaamohanad169-ship-it
alaamohanad169-ship-it requested a review from a team June 8, 2026 13:51
- Add hermes cron daemon subcommand for headless/standalone operation
- Add gateway lifecycle command defense (#30719) in cron_create()
- Fix null-repeat bug in cron_list (job.get('repeat') or {})
- _GATEWAY_LIFECYCLE_PATTERNS to block gateway restart/stop/kill in cron jobs

Co-authored-by: Ash <alaamohanad169-ship-it@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron jobs never execute: last_run_at always null after manual trigger

2 participants