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
Install
logicpacks pack use always-on-agents-public/cron-and-queuesget_pack always-on-agents-public/cron-and-queuesThe 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
- Prefer systemd timers (Persistent=true catches missed runs) or launchd StartInterval on the Mac; cron only where nothing else exists.
- 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). - Make the job idempotent: keep a state file of processed ids; write output atomically (tmp + rename).
- Log each run (start, end, result) to a JSON-lines file; a watchdog alerts if the last success is too old.
- 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.