Cron management

From grandamenium/cortextos · View interactive version

Cron management is an AI agent skill from the GitHub repository grandamenium/cortextos. Manage scheduled tasks (crons). Use when: setting up crons on session start, creating new recurring tasks, or troubleshooting scheduled tasks.

How to use this skill

Skill file

Cron Management

Your scheduled tasks are daemon-managed external crons. They are stored in

${CTX_ROOT}/state/{agent}/crons.json and scheduled by the cortextOS daemon.

Crons survive agent restarts, context compactions, and daemon restarts automatically —

you do NOT need to recreate them on session start.


On Session Start

Check that your crons are registered. You do not need to recreate them.

# List all crons with next_fire_at
cortextos bus list-crons $CTX_AGENT_NAME

If a cron is missing (not in the list), add it:

cortextos bus add-cron $CTX_AGENT_NAME <name> <interval|cron-expr> "<prompt>"
# Examples:
cortextos bus add-cron $CTX_AGENT_NAME heartbeat 4h "Run heartbeat protocol"
cortextos bus add-cron $CTX_AGENT_NAME morning-briefing "0 9 * * *" "Send morning briefing"

Adding a New Cron

# Interval shorthand (s/m/h/d/w)
cortextos bus add-cron $CTX_AGENT_NAME <name> <interval> "<prompt>"

# 5-field cron expression (minute hour dom month dow)
cortextos bus add-cron $CTX_AGENT_NAME <name> "<cron-expr>" "<prompt>"

The cron is written to crons.json atomically and the scheduler is reloaded.

No /loop call needed — the daemon fires crons directly into your PTY.

manualFireDisabled: If you want a cron to only fire on schedule (not manually

test-fired from the dashboard), set manualFireDisabled: true in the definition.

Contact the operator or use the dashboard edit form to set this flag.


Removing a Cron

cortextos bus remove-cron $CTX_AGENT_NAME <name>

Updating a Cron

Use the dashboard (/workflows/[agent]/[name]) or the bus command (if available):

cortextos bus update-cron $CTX_AGENT_NAME <name> --schedule <new-schedule>
cortextos bus update-cron $CTX_AGENT_NAME <name> --prompt "<new-prompt>"
cortextos bus update-cron $CTX_AGENT_NAME <name> --enabled false

Checking Execution History

# Recent execution log (fired / retried / failed entries)
cortextos bus get-cron-log $CTX_AGENT_NAME

# Filtered to a specific cron
cortextos bus get-cron-log $CTX_AGENT_NAME --cron <name>

Cron Expiry

External crons do not expire. They fire on schedule until disabled or removed.

The old 3-day /loop expiry no longer applies.


Troubleshooting

Cron not firing:

  1. cortextos bus list-crons $CTX_AGENT_NAME — confirm it is registered and has a next_fire_at
  2. cortextos bus get-cron-log $CTX_AGENT_NAME — check for status: retried or status: failed entries
  3. If PTY injection is failing, check the daemon log: ~/.cortextos/$CTX_INSTANCE_ID/logs/$CTX_AGENT_NAME/

Cron fires but agent does not react:

crons.json corrupted:

Crons disappeared after daemon reload (reload-to-empty):


Migration from config.json (legacy)

If your agent was set up before the external-crons migration, your crons lived in

config.json. The daemon auto-migrates them to crons.json on first boot.

A .crons-migrated marker file prevents re-runs. See CRONS_MIGRATION_GUIDE.md

for details and manual migration instructions.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.