Skip to content

Packs / always-on-agents-public

cron-and-queues

Scheduled jobs that don't overlap or vanish: cron/systemd timers with locks, idempotent state, run logs

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-always-on-agents-public

Install

logicpacks pack use always-on-agents-public/cron-and-queues
get_pack always-on-agents-public/cron-and-queues

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: self-hosted
  • Checks: 1 in outcome/checks.yaml
  • Code: run_once.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

Recurring jobs (scrapes, syncs, reports) run on schedule, never overlap, survive reboots, record each run, and are safe to re-run.

Steps

  1. Prefer systemd timers (Persistent=true catches missed runs) or launchd StartInterval on the Mac; cron only where nothing else exists.
  2. Wrap the job with a lock: flock -n /run/lock/job.lock job.sh (Linux) or the Python lock in code/run_once.py (portable).
  3. Make the job idempotent: keep a state file of processed ids; write output atomically (tmp + rename).
  4. Log each run (start, end, result) to a JSON-lines file; a watchdog alerts if the last success is too old.
  5. For bursts of work, a simple SQLite queue table (status, attempts, next_run_at) beats an external queue SaaS.

Edge cases

  • Two schedulers (cron + timer) for the same job = duplicate runs.

Don'ts

  • Don't let a job run forever: always set a timeout.
  • Never put a password, token or key value in this pack: use the env NAMES in pack.yaml and lp key add NAME.