# Timer

The timer runs `fleetrc sync` on a schedule, with no agent involved. Use it on a machine where no agent runs, such as a server. Everywhere else, [session hooks](https://fleetrc.loadsheet.dev/guide/hooks-and-mcp#session-hooks) start the syncs.

```sh
fleetrc timer install
fleetrc timer status
fleetrc timer remove
```

`init --timer` installs it with the rest of the setup, and `fleet init --timer` does the same on each host.
| Command | What it does | Exit code |
| --- | --- | --- |
| `timer install` | Installs the timer, or updates it. | `0`, or `1` when it cannot install |
| `timer status` | Shows whether the OS has it, its last and next run, and its log. | `0` when installed, else `1` |
| `timer remove` | Stops the timer and deletes its files. | `0` |

`install` and `remove` take `--dry-run`:

```sh
fleetrc timer install --dry-run
```

```txt
timer fleetrc-sync: `/usr/bin/node /home/me/.local/state/fleetrc/app/cli.mjs sync` on "*/30 * * * *" (the machine's time zone, now Europe/Madrid)
would install a systemd user timer
```

## Schedule

The manifest's `timer` field sets the schedule. Both keys are optional.

```json [.fleetrc/manifest.json]
{
  "timer": { "cron": "0 */2 * * *", "timeZone": "Europe/Madrid" }
}
```

| Key | Default | Meaning |
| --- | --- | --- |
| `cron` | `*/30 * * * *` | Five fields: minute, hour, day of month, month, day of week. |
| `timeZone` | `local` | An IANA name such as `Europe/Madrid` or `UTC`, or `local` for the machine's zone. |

fleetrc refuses a cron or zone it cannot read when it loads the manifest. After you change either, run `timer install` again. [`doctor`](https://fleetrc.loadsheet.dev/reference/doctor) warns until you do.

## Where it runs

| System | Scheduler |
| --- | --- |
| Linux | A systemd user timer, `fleetrc-sync.timer`, in `~/.config/systemd/user` |
| macOS | A launchd agent, `~/Library/LaunchAgents/fleetrc-sync.plist` |
| Windows | A Task Scheduler task |

launchd and Task Scheduler run in the machine's time zone, so a `timeZone` that gives other times there fails to install. Each run appends to `fleetrc-sync.log` in the state folder's `logs` directory.

## Linger on Linux

A systemd user timer stops when you log out unless lingering is on. On a server, turn it on once:

```sh
loginctl enable-linger "$USER"
```

`timer install` and `timer status` say when linger is off, and `doctor` reports it as `systemd linger`.

A container or WSL1 has no systemd user manager and cannot have a timer. `timer install` exits `1` and prints a crontab line that runs `fleetrc sync` instead.

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://fleetrc.loadsheet.dev/raw/guide.md)
- [Installation](https://fleetrc.loadsheet.dev/raw/guide/installation.md)
- [The manifest](https://fleetrc.loadsheet.dev/raw/guide/manifest.md)
- [Syncing](https://fleetrc.loadsheet.dev/raw/guide/sync.md)
- [Hooks and MCP servers](https://fleetrc.loadsheet.dev/raw/guide/hooks-and-mcp.md)
- [Fleet](https://fleetrc.loadsheet.dev/raw/guide/fleet.md)
- [Timer](https://fleetrc.loadsheet.dev/raw/guide/timer.md) (this page)
- [Agents](https://fleetrc.loadsheet.dev/raw/guide/agents.md)

Next: [Agents](https://fleetrc.loadsheet.dev/raw/guide/agents.md)

All pages: [llms.txt](https://fleetrc.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/fleetrc/issues). Report a security vulnerability privately, never in a public issue.
