Workflow Scheduling (Schedule)
What is the Schedule
Section titled “What is the Schedule”The Schedule system allows workflows to run automatically at defined intervals using cron expressions. Internally, the system uses the node-schedule library to manage scheduled jobs.
This is useful for recurring tasks such as generating reports, synchronizing data with external systems, sending periodic emails, or running maintenance processes.
How to Activate a Schedule
Section titled “How to Activate a Schedule”- In the workflow editor, enable the
active_schedule: trueproperty. - Define the cron expression in the
schedulefield. - The workflow must have a Start node as the trigger (not a Webhook node).
- When saving the workflow, the workflowManager registers the job automatically.
Once configured, the workflow will run automatically according to the frequency defined in the cron expression, without the need for manual intervention.
Cron Expression Format
Section titled “Cron Expression Format”Cron expressions consist of 5 fields separated by spaces:
* * * * *| | | | || | | | +-- Day of the week (0-7, where 0 and 7 = Sunday)| | | +---- Month (1-12)| | +------ Day of the month (1-31)| +-------- Hour (0-23)+---------- Minute (0-59)Special Characters
Section titled “Special Characters”| Character | Meaning |
|---|---|
* | Any value |
, | List of values (e.g.: 9,18 = 9 and 18) |
- | Range of values (e.g.: 1-5 = Monday to Friday) |
/ | Increment (e.g.: */5 = every 5 units) |
Common Expression Examples
Section titled “Common Expression Examples”| Expression | Description |
|---|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
*/15 * * * * | Every 15 minutes |
0 * * * * | Every hour (at minute 0) |
0 9 * * * | Daily at 9:00 AM |
0 9,18 * * * | Twice a day (9:00 AM and 6:00 PM) |
0 9 * * 1-5 | Monday to Friday at 9:00 AM |
0 0 * * 0 | Every Sunday at midnight |
0 0 1 * * | First day of each month at midnight |
0 8 1 1 * | January 1st at 8:00 AM |
30 2 * * * | Daily at 2:30 AM |
Schedule Management
Section titled “Schedule Management”The system provides the following functions to manage scheduled workflows:
loadScheduledWorkflows()
Section titled “loadScheduledWorkflows()”Loads all workflows with an active schedule when the server starts. It runs automatically during system startup.
reloadSingleWorkflow(id)
Section titled “reloadSingleWorkflow(id)”Reloads a specific workflow without needing to restart the server. Useful when the cron expression is modified or the schedule of an individual workflow is enabled/disabled.
getNextWorkflowRuns(ids, limit)
Section titled “getNextWorkflowRuns(ids, limit)”Gets the upcoming scheduled executions for one or more workflows. Receives an array of IDs and a result limit. Useful for showing the user when their workflow will execute.
In-Memory Storage
Section titled “In-Memory Storage”Scheduled jobs are stored in the Node.js process memory. This means they do not persist between server restarts. However, when the server starts, loadScheduledWorkflows() takes care of reloading all active jobs from the database.
Execution Behavior
Section titled “Execution Behavior”- Each scheduled execution generates a unique workflowId, which allows tracking each instance independently.
- The workflow executes as if it were a manual trigger, that is, without query params or webhook data.
- The Start node provides the initial data configured in the workflow.
- If the previous execution of the same workflow is still running when the next interval arrives, a new instance is launched in parallel. It does not wait for the previous one to finish.
Delay Within the Workflow - Difference from Schedule
Section titled “Delay Within the Workflow - Difference from Schedule”It is important not to confuse the Schedule with the Delay node:
| Feature | Schedule | Delay |
|---|---|---|
| Function | Starts new workflows periodically | Pauses a workflow at a specific point |
| Scope | Creates new execution instances | Affects only the current instance |
| Configuration | Cron expression in the workflow | Date/time or duration in the node |
| Management | workflowManager and node-schedule | delayMonitorService |
Delay Node in Detail
Section titled “Delay Node in Detail”- The Delay node pauses the execution of a workflow at a specific point in the flow.
- It schedules resumption at a future date and time.
- It uses the delayMonitorService to manage flow resumption when the configured time is reached.
- The workflow state is persisted so it can be resumed even if the server restarts.
In summary: the Delay pauses ONE flow that is already running, while the Schedule STARTS new flows periodically.
Example: Automatic Daily Report
Section titled “Example: Automatic Daily Report”This example shows a workflow that generates and sends a daily sales report Monday through Friday at 9:00 AM:
Start (schedule: "0 9 * * 1-5") -> SQL Query (get today's data) -> DataTransform (format report) -> SendMail (send report) -> EndDescription of each step:
- Start: Runs automatically Monday through Friday at 9:00 AM.
- SQL Query: Executes a SQL query to get the previous day’s sales data.
- DataTransform: Formats the data into a suitable structure for the report (tables, totals, etc.).
- SendMail: Sends the report via email to the configured recipients.
- End: Finishes the workflow execution.
Example: Periodic Synchronization
Section titled “Example: Periodic Synchronization”This example shows a workflow that queries an external API every 30 minutes and saves new data:
Start (schedule: "*/30 * * * *") -> HTTP (query external API) -> Decision (is there new data?) -> true: Iterator (process each record) -> DataStore (save) -> false: End -> Merge -> EndDescription of each step:
- Start: Runs automatically every 30 minutes.
- HTTP: Makes a request to the external API to get updated data.
- Decision: Evaluates whether the response contains new data that needs to be processed.
- Iterator: If there is new data, iterates over each record individually.
- DataStore: Saves each record to the database.
- Merge: Joins the flow branches (true/false) to continue toward the end.
- End: Finishes the workflow execution.