Hivra
Free tool. No signup.

Headless agent daemon builder

Schedule Claude Code (claude -p) or Codex (codex exec) to run unattended without silent PATH failures, overlapping jobs, or runaway loops.

Choose your CLI, scheduler, cadence, permission boundary, and max-turn cap. The builder outputs a ready-to-save run-agent.sh wrapper with flock -n overlap protection plus the matching systemd unit/timer, macOS launchd plist, or crontab entry.

Optional repository paths and task prompts stay strictly in your browser and never enter shared links.

Passed as --max-turns for Claude Code; 30-minute wall timeout applies to both.

Overlap protection

Stays in your browser and never enters share links.

Schedulersystemd
Overlap guardflock -n guard
Runaway cap25 turns + 30m

Generates run-agent.sh with explicit PATH, flock -n guard, and 25 turns + 30m, paired with a systemd schedule that will not pile up overlapping agent processes.

run-agent.sh
#!/usr/bin/env bash
set -Eeuo pipefail

# Explicit PATH so cron/systemd finds node, claude, or codex
export PATH="$HOME/.local/bin:/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:$PATH"
WORKDIR='/home/agent/repo'
LOGFILE="$HOME/agent-daemon.log"

LOCKFILE="/tmp/hivra-headless-agent.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
  echo "[$(date -Is)] Previous run still active; skipping." >> "$LOGFILE"
  exit 0
fi

cd "$WORKDIR"
echo "[$(date -Is)] Starting scheduled agent run" >> "$LOGFILE"
timeout 1800 claude -p 'Run the test suite, inspect any failure, open a scoped fix on a new branch, and print a short summary.' \
  --allowedTools "Read,Edit,Write,Glob,Grep,Bash(npm test:*)" \
  --max-turns 25 \
  --output-format json >> "$LOGFILE" 2>&1
echo "[$(date -Is)] Run finished" >> "$LOGFILE"
systemd user service + timer (~/.config/systemd/user/)
# Save as ~/.config/systemd/user/agent-job.service
[Unit]
Description=Scheduled headless AI coding agent run
After=network-online.target

[Service]
Type=oneshot
WorkingDirectory=/home/agent/repo
ExecStart=/usr/bin/env bash /home/agent/repo/run-agent.sh
NoNewPrivileges=true

# Save as ~/.config/systemd/user/agent-job.timer
[Unit]
Description=Schedule for headless AI coding agent

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target
Enable and verify
chmod +x run-agent.sh && systemctl --user daemon-reload && systemctl --user enable --now agent-job.timer && loginctl enable-linger $USER
Share this daemon preset (excludes local path and prompt)

Notes: cron and systemd start with a minimal PATH, which is the most common reason scheduled agent jobs fail silently. The wrapper exports standard user bin paths and logs stdout and stderr to ~/agent-daemon.log. CLI flags checked as of October 2026.

A laptop misses overnight cron and launchd schedules whenever the lid closes. If you want a Linux computer that stays on without managing home uptime, Hivra starts at $9.99 a month for 2 vCPU and 4 GB, not paused for inactivity.

Start on the $9.99 plan

How this headless daemon builder works

Non-interactive CLI flags (`claude -p`, `--allowedTools`, `--max-turns`, `--output-format json`, and `codex exec --sandbox`) come from Anthropic's Claude Code CLI reference and OpenAI's Codex CLI reference. Sources: Anthropic Claude Code headless and print mode docs, OpenAI Codex CLI exec and sandbox reference.

Linux systemd timer syntax (`OnCalendar`, `Persistent=true`, `Type=oneshot`) follows the freedesktop systemd.timer manual page. Sources: systemd.timer(5) manual page.

Every wrapper script includes `set -Eeuo pipefail`, an explicit `PATH`, a 30-minute `timeout 1800` wall clock ceiling, and optional `flock -n` locking to stop concurrent runs from corrupting a git checkout.

Generation and file downloads run entirely in your browser. Typed paths and prompts never leave your machine.

Last checked October 2026.

Worked examples

Nightly scoped Claude Code run on a Linux systemd timer

Inputs: Claude Code, systemd, nightly 03:00, workspace-only, 25 max turns, flock enabled.

run-agent.sh (flock -n 9 + timeout 1800 claude -p --max-turns 25) + agent-job.timer

Runs at 03:00 with explicit PATH, bounded turn count, and zero overlapping processes if a run runs long.

Read-only Codex audit every 6 hours via crontab

Inputs: Codex CLI, cron, every 6 hours, readonly, flock enabled.

0 */6 * * * /usr/bin/env bash '/home/agent/repo/run-agent.sh' (codex exec --sandbox read-only)

Safe recurring code health or log audit that cannot modify repository files.

Weekday macOS launchd plist for daytime runs

Inputs: Claude Code, launchd, weekdays 07:00, workspace-only.

com.agent.daemon.plist with StartCalendarInterval weekdays 07:00

Runs on a plugged-in Mac when awake, with a clear caveat that closed-lid sleep pauses scheduled runs.

Cite this page

Hivra, "Headless Agent Daemon Builder", https://hivra.cloud/tools/headless-agent-daemon-builder, facts last checked October 2026.

Source: <a href="https://hivra.cloud/tools/headless-agent-daemon-builder">Hivra</a>, Headless Agent Daemon Builder, facts last checked October 2026.

Common questions

Why do scheduled Claude Code or Codex cron jobs fail silently?

cron and systemd launch with a minimal PATH that omits ~/.local/bin, /usr/local/bin, and /opt/homebrew/bin, so claude or codex exits with command not found. Exporting PATH inside a wrapper script fixes this.

Why use flock -n in a scheduled agent wrapper?

If a 03:00 run takes longer than expected or hangs on a test suite, flock -n prevents the next scheduled trigger from launching a second overlapping agent in the same git working tree.

Should I prefer systemd timers over crontab on Linux?

Yes. systemd user timers give you journalctl logs, Persistent=true catch-up after reboots, and clean NoNewPrivileges hardening. Remember to run loginctl enable-linger $USER so user timers fire without an active SSH login.

How do I cap runaway loops in headless Claude Code runs?

Combine --max-turns (for example --max-turns 25) with a Linux timeout wrapper such as timeout 1800 so a stuck retry loop exits cleanly instead of burning quota all night.

Can macOS launchd run my agent while the laptop lid is closed?

No. When a Mac laptop sleeps, launchd pauses scheduled jobs until the machine wakes. For reliable unattended schedules, run systemd timers on a dedicated Linux computer.

Are my custom repository path and task prompt included in share links?

No. Share links serialize only the structured dropdown and checkbox choices. Typed paths and prompts remain in your browser.

When you need a computer that stays on

If you want the computer to stay on after you leave your desk, Hivra offers a managed computer starting at $9.99 a month for 2 vCPU and 4 GB of RAM. A paid Hivra Cloud computer stays on and is not paused for inactivity. The plan does not include AI usage. Bring your own account or key where the agent supports it, or pay with Hivra credits. Claude Code can use your own Anthropic sign-in or Hivra credits. There is a 7-day money-back guarantee on card payments.

Hivra is independent and is not affiliated with Anthropic or OpenAI.