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

# Schedule examples

> Cron a queue job. Redis keeps the schedule if a process restarts.

# Schedule examples

Runnable file: [agentium-examples/scheduling/cron-agent.ts](https://github.com/agentiumOS/agentium-examples/blob/main/scheduling/cron-agent.ts).

Guide: [Schedules](/schedules/overview)

Needs Redis on `localhost:6379`.

***

## 1. Every 5 minutes + every morning

```typescript theme={null}
import { Agent, openai } from "@agentium/core";
import { AgentQueue, AgentWorker } from "@agentium/queue";

const reportAgent = new Agent({
  name: "report-agent",
  model: openai("gpt-4o-mini"),
  instructions: "You write a short status line.",
});

const connection = { host: "localhost", port: 6379 };
const queue = new AgentQueue({ connection, queueName: "scheduled-runs" });

await queue.schedule({
  id: "status-check",
  cron: "*/5 * * * *",
  agent: { name: "report-agent", input: "System status check." },
});

await queue.schedule({
  id: "daily-report",
  cron: "0 9 * * *",
  timezone: "Asia/Kolkata",
  agent: {
    name: "report-agent",
    input: "Write the daily report.",
    sessionId: "daily-report",
  },
});

const worker = new AgentWorker({
  connection,
  queueName: "scheduled-runs",
  agentRegistry: { "report-agent": reportAgent },
});

worker.start();
```

Same `sessionId` on the daily job → the agent can see yesterday's report.
