> ## Documentation Index
> Fetch the complete documentation index at: https://docs.duckbrain.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# schedule

> Run sync automatically on an interval — launchd on macOS, systemd on Linux

```bash theme={null}
duckbrain schedule --every 6h    # install / update the schedule
duckbrain schedule off           # remove it
```

`--every` takes minutes or hours (`30m`, `6h`). Re-running with a new interval replaces the old one. Logs land at `~/.duckbrain/<instance>/logs/sync.log`, and the schedule pins the instance that was active when you ran the command (`DUCKBRAIN_INSTANCE`).

## macOS: launchd

Installs a LaunchAgent at `~/Library/LaunchAgents/sh.duckbrain.sync.plist`. Uses **launchd**, not cron: jobs missed while the laptop sleeps fire on wake instead of being skipped.

## Linux: systemd user timer

Installs `duckbrain-sync.service` + `duckbrain-sync.timer` under `~/.config/systemd/user/` and enables the timer. `Persistent=true` is the systemd analog of launchd's fire-on-wake: a run missed while the machine was off fires at next boot.

<Note>
  On a headless VM or server, run `loginctl enable-linger $USER` once so the user timer runs without an active login session.
</Note>

```bash theme={null}
systemctl --user list-timers duckbrain-sync.timer   # inspect
journalctl --user -u duckbrain-sync.service         # unit logs (sync output goes to sync.log)
```

## Verify

```bash theme={null}
# macOS
launchctl list | grep duckbrain
# Linux
systemctl --user status duckbrain-sync.timer
```

Scheduled runs are safe alongside [hook-triggered syncs](/commands/hooks) and manual runs: `sync` holds a single-flight lock, so overlapping triggers no-op instead of racing.
