---
title: ".scheduler()"
description: "Replace the process-local scheduler used by recurring tasks."
---

> Documentation Index
> Fetch the complete documentation index at: https://xsaf.ilha.build/llms.txt
> Use this file to discover all available pages before exploring further.

# .scheduler()

## Signature

```ts
agent.scheduler(driver: XsafSchedulerDriver): XsafAgent
```

## Usage

```ts
import { cron } from "@xsaf/agent/scheduler/cron";

const bot = agent(config).scheduler(cron()).schedule({
  cron: "*/15 * * * *",
  prompt: "Check service status",
});
```

Only one scheduler may be configured. Without `.scheduler()`, scheduled tasks use XSAF's built-in process-local cron scheduler.

Register the scheduler before [`.schedule()`](/xsaf/schedule). Custom drivers implement the structural `XsafSchedulerDriver` contract exported from `@xsaf/agent/types`.

Source: https://xsaf.ilha.build/xsaf/scheduler/index.mdx
