> ## 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.

# 08.8 workflow schedule

# Workflow Schedule Template

The **Workflow Schedule** template demonstrates how BindAI workflows can execute automatically at predefined times or recurring intervals without requiring manual input.

Instead of waiting for a user request, the scheduler continuously checks registered schedules and launches workflows whenever they become due.

This template introduces time-based workflow automation.

***

# Purpose

This template demonstrates how to:

* create a workflow schedule
* register scheduled workflows
* execute workflows automatically
* configure recurring execution
* reschedule future runs

It introduces background automation into the workflow system.

***

# Workflow Structure

The scheduled workflow itself is identical to any other workflow.

```text id="ws1" theme={null}
Start

↓

Agent

↓

End
```

The difference is **how the workflow is started**.

***

# Scheduling Architecture

Execution begins with the scheduler.

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

↓

Workflow Scheduler

↓

Workflow Executor

↓

Workflow Result
```

The scheduler decides **when** execution begins.

***

# Scheduler Flow

The scheduler continuously checks registered schedules.

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

↓

Due?

↓

Execute Workflow
```

Only workflows whose scheduled time has arrived are executed.

***

# Workflow Schedule

A schedule describes when a workflow should run.

Typical information includes:

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

Example:

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

***

# One-Time Schedule

A workflow may execute only once.

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

↓

Execute

↓

Finished
```

After completion, no future execution occurs unless another schedule is created.

***

# Recurring Schedule

Recurring schedules automatically calculate the next execution.

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

↓

Next Run

↓

Run

↓

Next Run
```

This allows continuous automation without user interaction.

***

# Example

Suppose a workflow runs every hour.

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

↓

10:00

↓

11:00

↓

12:00
```

After each execution, the scheduler updates the next execution time.

***

# Automatic Execution

Applications do not manually start scheduled workflows.

```text id="ws8" theme={null}
Scheduler

↓

Workflow

↓

Result
```

The scheduler handles execution automatically.

***

# Typical Use Cases

Scheduled workflows are commonly used for:

* daily reports
* periodic summaries
* knowledge synchronization
* document indexing
* monitoring services
* automated backups
* recurring maintenance
* data synchronization

These workflows usually operate without direct user interaction.

***

# Scheduler vs Loop

Scheduling and loops both involve repeated execution but solve different problems.

| Scheduler                       | Loop                        |
| ------------------------------- | --------------------------- |
| Repeats over time               | Repeats immediately         |
| Creates new workflow executions | Continues current execution |
| Background automation           | Runtime iteration           |
| Time-based                      | Logic-based                 |

Schedulers manage **when** workflows begin.

Loops manage **how** a workflow repeats internally.

***

# Time Zones

Production scheduling should use timezone-aware timestamps.

```text id="ws9" theme={null}
UTC

↓

Convert

↓

Local Time
```

Using timezone-aware datetimes avoids problems caused by:

* daylight saving time
* regional deployments
* UTC/local conversions

***

# Enabling and Disabling

Schedules may be enabled or disabled.

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

↓

Execute

Disabled

↓

Skip
```

Disabled schedules remain registered but are ignored until re-enabled.

***

# Monitoring Scheduled Workflows

Production systems should monitor:

* successful executions
* failed executions
* execution duration
* missed schedules
* next execution time
* recurring failures

Monitoring ensures recurring automation remains healthy.

***

# Best Practices

* Use timezone-aware datetimes.
* Keep scheduled workflows idempotent whenever possible.
* Choose sensible execution intervals.
* Avoid overlapping executions of the same workflow unless intentionally supported.
* Monitor recurring workflow health.
* Log every scheduled execution.

***

# Related Templates

The Scheduling template works well with:

* Workflow Retry
* Workflow Timeout
* Workflow Human

These templates together enable reliable production automation.

***

# Summary

The **Workflow Schedule** template demonstrates how BindAI automatically executes workflows based on predefined schedules.

By separating scheduling from execution, workflows can run continuously in the background, enabling recurring AI automation while keeping workflow logic completely independent from timing concerns.
