Skip to content

Scheduler and Jobs

CortexPrism edited this page Jun 17, 2026 · 1 revision

Scheduler & Jobs

CortexPrism includes a SQLite-persisted cron job scheduler for running background tasks, memory consolidation, and user-defined jobs.

Architecture

The scheduler daemon runs as part of the supervisor process:

supervisor-process.ts
  └── scheduler-process.ts   ← DB polling: runs cron jobs every 30s
        memory consolidation, scheduled commands

Job States

  • pending — Scheduled, waiting for execution
  • running — Currently executing
  • completed — Finished successfully
  • failed — Finished with error
  • cancelled — Manually cancelled

Retry Logic

Failed jobs are automatically retried with exponential backoff.

CLI Commands

cortex jobs list                    # List all jobs
cortex jobs list --status pending   # Filter by status
cortex jobs create <name> <cron> <command>  # Create a scheduled job
cortex jobs delete <job-id>         # Remove a job
cortex jobs trigger <job-id>        # Run a job immediately
cortex jobs cancel <job-id>         # Cancel a running job

Cron Expression Format

Standard 5-field cron:

minute hour day month weekday

Examples:

  • 0 * * * * — Every hour
  • 0 2 * * * — Every day at 2 AM
  • */30 * * * * — Every 30 minutes

Scheduled Tasks

Memory Consolidation

The scheduler automatically runs:

  • Hourly: Episodic memory consolidation
  • Daily: Semantic decay updates
  • Weekly: Reflection pattern consolidation

Plugin Update Checks

When pluginUpdate.checkOnStartup is enabled, the scheduler periodically checks for plugin updates.

REST API

Method Path Description
GET /api/jobs?status=pending List jobs
POST /api/jobs Create a job
POST /api/jobs/:id/cancel Cancel a job
POST /api/jobs/:id/trigger Trigger immediately
DELETE /api/jobs/:id Delete a job

Web UI

The Jobs tab in the Web UI shows:

  • All scheduled jobs with status indicators
  • Next run time
  • Last execution result
  • Manual trigger and cancel buttons

See Also

Clone this wiki locally