---
title: "Scheduler"
canonical: "https://docs.devo.com/space/latest/95214759/Scheduler"
format: markdown
---
> Macro (toc)

## Description

This unit is a [Source ](https://devodocs.atlassian.net/wiki/spaces/latest/pages/95213765)unit type.

The Scheduler unit is a more granular version of the [Generator](https://devodocs.atlassian.net/wiki/spaces/latest/pages/95214668) unit, allowing for more concise configurations of the period and frequency of event generation.

This unit generates events periodically using a cron expression, based on the event frequency, timezone, and content settings configured in the properties.

An event entering via the *do *port provides the start date for the event generation. The input event field used for the start date is configured in the unit properties. If no field is configured, system time is used by default.

If the start date is before the current moment, the unit will generate at once all events that would have been generated according to the expression, and then continue from now.

If the start date is after the current moment, the unit will start generating events from that moment.

If no dates are configured, the unit will start generating events when the Flow begins and stops when the Flow ends.

Events entering via the *stop *port signal the end of event generation. If no field is configured, the default value is *null.*

If the unit has already stopped, an event reaching the *stop* port will be discarded.

Events are output through the *out *port with the results of the cron expression.

If an error occurs, the events are enriched with standard error fields and set to the *error* output port.

![image](media://330112e2-93f1-422c-a3e0-97ade14009a9)

## Configuration

After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:

| **Tab** | **Field** | **Description** |
| --- | --- | --- |
| *General* | *Name* | Enter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed. |
| *Cron expression* | Enter the cron expression that defines when the events will be generated.<br>Click the **Help** tool icon to help you to generate the Cron expression: |
| *Autostart* | Indicate how to signal for the unit to start.<br>If switched *on***, **the unit will start automatically when the Flow diagram starts.<br>If switched *off***, **the unit requires an event from the *do* port to start. |
| *Time field name* | Enter the name of an input event field containing the period start date to be added to the output event (optional). |
| *Counter field name* | Enter the name of an input event field containing an event order number, starting at zero, to be added to the output event (optional). |
| *Time zone* | Enter the time zone to be used to schedule the unit. |
| *Start field* | Enter the input event field to be used as the start date. If left blank, the default value is *now.* |
| *End field* | Enter the input event field to be used as the end date. If left blank, the default value is *null.* |

## Input ports

| **Port** | **Description** |
| --- | --- |
| *do* | Input events determining the start date for event generation. The field used for the start date is configured in the unit properties. |
| *stop* | Input events determining the end of event generation. The field used for the end date is configured in the unit properties. |

## Output ports

| **Port** | **Description** |
| --- | --- |
| *out* | this port outputs the indicated number of events at the given frequency, with optional fields containing the event order number and period start date. |
| *error* | This port outputs events that generated an error when evaluated against the expression. Standard error fields (error, exception) are added to the output events. |

## Example

Imagine you wish to generate events every second.

You can specify an expression in the Scheduler unit to fire events to a **my.app **table every second. To do it, we add a [Tick ](https://devodocs.atlassian.net/wiki/spaces/latest/pages/95214835)unit to fire the request every time we need it. Then, connect it to the Scheduler unit through its *in* input port. Finally, we can send the events to Devo by connecting the Scheduler *out *output port to a [Devo Sink ](https://devodocs.atlassian.net/wiki/spaces/latest/pages/95214553)unit.

![image](media://8d8676e1-2d7c-4689-b253-8e73aa88467e)

In the Tick unit properties, set the fields to transform in the **Fields **tab.

![image](media://30ee8aca-d411-45f4-9c33-f5ed8998a781)

In the Scheduler unit properties, specify the **Cron expression,** as well as the following fields:

![image](media://76c81da0-c901-4ccf-9d1b-ab85c980a2dc)

You can click the **Help **icon to help you to generate the **Cron** **expression**:

![image](media://99901655-eb58-4ace-897b-8b6e10372c3e)

In the Devo Sink unit properties, specify the **my.app **table.

> ℹ️ After [saving and starting](https://devodocs.atlassian.net/wiki/spaces/latest/pages/95213352) the Flow, you must click the red button of the Tick unit to begin sending events.

### 📁 Download this example

You can try this flow by downloading the following JSON file and uploading it to your domain using the **Import **option.