Scheduled tasks system: systemd timers + Claude CLI as cowork alternative #2

Open
opened 2026-02-28 04:52:23 +00:00 by cal · 0 comments
Owner

Summary

Build a scheduled tasks system using systemd timers and claude -p (headless mode) to replicate Claude cowork's scheduled tasks feature on unsupported platforms (Nobara/Fedora).

Note: This may end up in its own repo rather than living here. Tracking the idea here since it originated from cognitive memory discussions and depends on multi-graph support (#1).

Motivation

Claude cowork's scheduled tasks feature is not available on Nobara. The core functionality — running Claude on a schedule with memory of prior runs — can be recreated with existing tools:

  • claude -p "prompt" for headless CLI execution
  • systemd timers for scheduling (preferred over cron for no-overlap, logging, Persistent=true)
  • Cognitive memory (with multi-graph support) for state persistence across runs

Proposed Architecture

Task directory structure

~/.claude/scheduled-tasks/
├── CLAUDE.md                    # Shared instructions for all scheduled tasks
├── memory/                      # Dedicated memory graph (requires #1)
├── server-health/
│   ├── task.yaml                # Schedule, prompt, allowed tools, etc.
│   ├── state.md                 # Rolling structured state (last run, findings)
│   └── logs/                    # Run output history
├── backup-check/
│   ├── task.yaml
│   ├── state.md
│   └── logs/
└── ...

Task config (task.yaml)

name: server-health
schedule: "*-*-* 06:00:00"      # systemd calendar syntax (daily at 6am)
prompt: |
  Check health of all monitored servers. Compare against prior state.
  Update state.md with current findings.
  Store any notable changes to cognitive memory.  
cwd: ~/.claude/scheduled-tasks/server-health/
allowed_tools:
  - Bash
  - Read
  - Write
  - mcp__cognitive-memory__*
model: sonnet
timeout: 300                     # seconds

Components needed

  1. Task runner wrapper — Shell script or Python CLI that:

    • Reads task.yaml
    • Invokes claude -p with the right flags (--cwd, --allowedTools, --model)
    • Captures output to logs/
    • Handles errors, timeouts, exit codes
    • Optionally sends notifications (Discord webhook) on failure or notable findings
  2. Task installer — Generates systemd timer + service units from task.yaml:

    • ~/.config/systemd/user/claude-task-{name}.service
    • ~/.config/systemd/user/claude-task-{name}.timer
    • systemctl --user enable --now claude-task-{name}.timer
  3. Task manager CLI — Simple interface for:

    • claude-tasks list — show all tasks, schedules, last run status
    • claude-tasks add <name> — scaffold a new task directory
    • claude-tasks run <name> — manual one-off execution
    • claude-tasks logs <name> — tail recent output
    • claude-tasks install/uninstall <name> — manage systemd units

Memory persistence (depends on #1)

  • Each run reads state.md for structured rolling state
  • Cognitive memory with graph: "scheduled-tasks" for higher-level insights
  • Task-specific tags (e.g., server-health, backup-check) for namespacing within the graph
  • Decay scoring isolated from the interactive session graph

Key design decisions to make

  • Python CLI vs shell scripts for the task runner/manager
  • Notification mechanism — Discord webhook, desktop notification, or both
  • Output retention — how many log files to keep per task
  • Auth/security — scheduled tasks run with full Claude CLI permissions; need to scope --allowedTools carefully
  • Cost guardrails — max tokens per run, daily budget caps
  • Depends on: #1 (multi-graph support)
  • Inspired by: Claude cowork scheduled tasks (not available on Nobara/Fedora)
## Summary Build a scheduled tasks system using systemd timers and `claude -p` (headless mode) to replicate Claude cowork's scheduled tasks feature on unsupported platforms (Nobara/Fedora). > **Note:** This may end up in its own repo rather than living here. Tracking the idea here since it originated from cognitive memory discussions and depends on multi-graph support (#1). ## Motivation Claude cowork's scheduled tasks feature is not available on Nobara. The core functionality — running Claude on a schedule with memory of prior runs — can be recreated with existing tools: - `claude -p "prompt"` for headless CLI execution - systemd timers for scheduling (preferred over cron for no-overlap, logging, `Persistent=true`) - Cognitive memory (with multi-graph support) for state persistence across runs ## Proposed Architecture ### Task directory structure ``` ~/.claude/scheduled-tasks/ ├── CLAUDE.md # Shared instructions for all scheduled tasks ├── memory/ # Dedicated memory graph (requires #1) ├── server-health/ │ ├── task.yaml # Schedule, prompt, allowed tools, etc. │ ├── state.md # Rolling structured state (last run, findings) │ └── logs/ # Run output history ├── backup-check/ │ ├── task.yaml │ ├── state.md │ └── logs/ └── ... ``` ### Task config (`task.yaml`) ```yaml name: server-health schedule: "*-*-* 06:00:00" # systemd calendar syntax (daily at 6am) prompt: | Check health of all monitored servers. Compare against prior state. Update state.md with current findings. Store any notable changes to cognitive memory. cwd: ~/.claude/scheduled-tasks/server-health/ allowed_tools: - Bash - Read - Write - mcp__cognitive-memory__* model: sonnet timeout: 300 # seconds ``` ### Components needed 1. **Task runner wrapper** — Shell script or Python CLI that: - Reads `task.yaml` - Invokes `claude -p` with the right flags (`--cwd`, `--allowedTools`, `--model`) - Captures output to `logs/` - Handles errors, timeouts, exit codes - Optionally sends notifications (Discord webhook) on failure or notable findings 2. **Task installer** — Generates systemd timer + service units from `task.yaml`: - `~/.config/systemd/user/claude-task-{name}.service` - `~/.config/systemd/user/claude-task-{name}.timer` - `systemctl --user enable --now claude-task-{name}.timer` 3. **Task manager CLI** — Simple interface for: - `claude-tasks list` — show all tasks, schedules, last run status - `claude-tasks add <name>` — scaffold a new task directory - `claude-tasks run <name>` — manual one-off execution - `claude-tasks logs <name>` — tail recent output - `claude-tasks install/uninstall <name>` — manage systemd units ### Memory persistence (depends on #1) - Each run reads `state.md` for structured rolling state - Cognitive memory with `graph: "scheduled-tasks"` for higher-level insights - Task-specific tags (e.g., `server-health`, `backup-check`) for namespacing within the graph - Decay scoring isolated from the interactive session graph ## Key design decisions to make - **Python CLI vs shell scripts** for the task runner/manager - **Notification mechanism** — Discord webhook, desktop notification, or both - **Output retention** — how many log files to keep per task - **Auth/security** — scheduled tasks run with full Claude CLI permissions; need to scope `--allowedTools` carefully - **Cost guardrails** — max tokens per run, daily budget caps ## Related - Depends on: #1 (multi-graph support) - Inspired by: Claude cowork scheduled tasks (not available on Nobara/Fedora)
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/claude-memory#2
No description provided.