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

# Scheduling

> Learn about job scheduling patterns

# Scheduling

Schedo.dev provides flexible scheduling options for running jobs, supporting cron expressions

## Cron Expressions

Jobs can be scheduled using standard cron expressions:

```typescript theme={null}
schedo.defineJob(
  'daily-backup',
  '0 0 * * *',    // Run at midnight every day
  async (ctx) => {
    // Job implementation
  }
);
```

### Cron Format

Cron expressions consist of five fields:

```
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday)
│ │ │ │ │
* * * * *
```

### Common Patterns

```typescript theme={null}
// Every minute
'* * * * *'

// Every 15 minutes
'*/15 * * * *'

// Every hour
'0 * * * *'

// Every day at midnight
'0 0 * * *'

// Every Monday at 9:00 AM
'0 9 * * 1'

// Every month on the 1st at midnight
'0 0 1 * *'
```

## Schedule Validation

Schedo.dev validates both cron expressions and intervals:

```typescript theme={null}
// Invalid cron expression
schedo.defineJob(
  'invalid-job',
  '0 24 * * *',    // 24 is invalid hour
  async (ctx) => {
    // Never runs - throws error during definition
  }
);
```

## Best Practices

2. **Consider Business Hours**
   ```typescript theme={null}
   // Run during business hours (9 AM - 5 PM on weekdays)
   '0 9-17 * * 1-5'
   ```

3. **Stagger High-Load Jobs**
   ```typescript theme={null}
   // Instead of all jobs at midnight
   '0 0 * * *'     // Job A
   '5 0 * * *'     // Job B
   '10 0 * * *'    // Job C
   ```

## Next Steps

<CardGroup cols={2}>
  <Card title="Error Handling" icon="shield" href="/core-concepts/error-handling">
    Learn about handling job failures
  </Card>

  <Card title="Monitoring" icon="chart-line" href="/core-concepts/monitoring">
    Monitor your scheduled jobs
  </Card>
</CardGroup>
