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

# 06.9 scheduling

# Scheduling

Scheduling allows workflows to execute automatically at predefined times or recurring intervals.

Instead of requiring manual execution, scheduled workflows run in the background whenever their configured schedule becomes due.

Scheduling is useful for automation, monitoring, maintenance, and recurring AI tasks.

***

# What is Workflow Scheduling?

A workflow schedule defines **when** a workflow should execute.

Conceptually:

```text id="sched1" theme={null}
Schedule

↓

Time Reached

↓

Execute Workflow
```

The scheduler continuously checks for workflows that are ready to run.

***

# Why Schedule Workflows?

Many business processes happen repeatedly.

Examples include:

* daily reports
* hourly monitoring
* nightly data synchronization
* recurring document processing
* periodic AI analysis
* automated maintenance

Scheduling removes the need for manual execution.

***

# Scheduler Architecture

BindAI separates scheduling from workflow execution.

```text id="sched2" theme={null}
Workflow Schedule

↓

Workflow Scheduler

↓

Workflow Executor

↓

Workflow Result
```

The scheduler determines **when** to execute.

The executor determines **how** to execute.

***

# Workflow Schedule

A workflow schedule contains timing information.

Typical properties include:

* workflow identifier
* next execution time
* execution interval
* enabled state

Example:

```python id="sched3" theme={null}
WorkflowSchedule(
    workflow_id="daily-report",
    next_run=...,
    interval_seconds=3600,
)
```

***

# Scheduler

The scheduler manages registered schedules.

Conceptually:

```text id="sched4" theme={null}
Schedule A

Schedule B

Schedule C

↓

Scheduler

↓

Due Workflows
```

Only workflows whose scheduled time has arrived are returned for execution.

***

# Due Workflows

During each scheduling cycle:

```text id="sched5" theme={null}
Current Time

↓

Compare

↓

Due?

↓

Execute
```

Future schedules remain inactive until their execution time arrives.

***

# Recurring Workflows

Recurring schedules automatically calculate their next execution.

```text id="sched6" theme={null}
Run

↓

Next Run

↓

Run

↓

Next Run
```

This allows workflows to repeat indefinitely.

***

# One-Time Execution

Schedules may also execute only once.

```text id="sched7" theme={null}
Scheduled Time

↓

Execute

↓

Finished
```

No additional execution occurs unless a new schedule is created.

***

# Rescheduling

After a recurring workflow finishes:

```text id="sched8" theme={null}
Workflow Complete

↓

Add Interval

↓

Next Execution Time
```

The scheduler updates the workflow's next execution automatically.

***

# Example

Suppose a workflow runs every hour.

```text id="sched9" theme={null}
09:00

↓

10:00

↓

11:00

↓

12:00
```

Each execution automatically schedules the following run.

***

# Background Automation

Scheduling enables continuous automation.

Examples include:

* checking system health
* generating summaries
* refreshing knowledge bases
* sending notifications
* cleaning temporary data
* processing queued documents

These workflows execute without user interaction.

***

# Scheduling vs Loops

Although both involve repeated execution, they solve different problems.

| Scheduling            | Loop                      |
| --------------------- | ------------------------- |
| Executes over time    | Executes immediately      |
| Time-based            | Logic-based               |
| Persistent            | Single workflow execution |
| Background automation | Runtime iteration         |

Loops repeat during one workflow execution.

Schedules create future workflow executions.

***

# Time Zones

Production scheduling should use timezone-aware timestamps.

Using timezone-aware datetime objects helps avoid issues caused by:

* daylight saving time
* server location differences
* UTC/local time conversions

Consistent timezone handling improves reliability.

***

# Enabling and Disabling

Schedules can be enabled or disabled.

```text id="sched10" theme={null}
Enabled

↓

Execute

Disabled

↓

Ignore
```

Disabled schedules remain registered but do not execute.

***

# Best Practices

* Use timezone-aware datetimes.
* Keep scheduled workflows idempotent whenever possible.
* Monitor recurring workflows.
* Use reasonable execution intervals.
* Avoid overlapping executions of the same workflow unless intentionally supported.
* Log execution history for troubleshooting.

***

# Summary

Workflow scheduling enables BindAI to execute workflows automatically based on predefined schedules.

By separating scheduling from execution, BindAI provides a flexible foundation for recurring automation while keeping workflow logic independent from timing concerns.
