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

# Jobs

> Schedule agent tasks

Agents can run on a schedule - daily reports, hourly checks, or one-time tasks.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Job Scheduling"
        A[⏰ Schedule] --> B[📋 Queue]
        B --> C[🤖 Agent]
        C --> D[📊 Result]
    end
    
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    
    class C agent
    class A,B,D tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

```

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent, Job } from 'praisonai';

    const agent = new Agent({
      instructions: 'Generate daily sales reports'
    });

    const job = new Job({
      agent,
      task: 'Create the daily sales summary',
      schedule: '0 9 * * *'  // Every day at 9 AM
    });

    await job.start();
    ```
  </Step>

  <Step title="With Configuration">
    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    const job = new Job({
      agent,
      task: 'Check system status',
      interval: '30m'  // Every 30 minutes
    });
    ```
  </Step>
</Steps>

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant Schedule
    participant Job
    participant Agent
    
    Schedule->>Job: Trigger (9 AM)
    Job->>Agent: Execute task
    Agent-->>Job: Complete
    Job->>Job: Schedule next run
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: String - Cron schedule
const job = new Job({
  agent,
  task: 'Daily report',
  schedule: '0 9 * * *'
});

// Level 2: Dict - With options
const job = new Job({
  agent,
  task: 'Check status',
  interval: '1h',
  runOnStart: true
});

// Level 3: Instance - Full control
const job = new Job({
  agent,
  task: 'Generate report',
  schedule: '0 9 * * 1-5',  // Weekdays only
  timezone: 'America/New_York',
  onComplete: (result) => sendEmail(result),
  retries: 2
});
```

***

## Schedule Types

| Type     | Example                       |
| -------- | ----------------------------- |
| Cron     | `'0 9 * * *'` (daily at 9 AM) |
| Interval | `'30m'`, `'1h'`, `'1d'`       |
| One-time | `new Date('2024-03-15')`      |

***

## API Reference

<Card title="SessionConfig" icon="code" href="/docs/sdk/reference/typescript/classes/SessionConfig">
  Session configuration
</Card>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use cron for fixed times">
    Cron is best for "every day at 9 AM" type schedules.
  </Accordion>

  <Accordion title="Handle failures">
    Set retries and notifications for important jobs.
  </Accordion>

  <Accordion title="Consider timezones">
    Always specify timezone for user-facing schedules.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Workflows" icon="diagram-project" href="/docs/js/workflows">
    Multi-step workflows
  </Card>

  <Card title="Execution" icon="play" href="/docs/js/execution">
    Execution settings
  </Card>
</CardGroup>
