Skip to content

Latest commit

 

History

History
162 lines (118 loc) · 6.45 KB

scheduled-cron.mdx

File metadata and controls

162 lines (118 loc) · 6.45 KB

Scheduled Cron Trigger

import { Callout } from 'nextra/components'; import { Steps } from 'nextra/components'; import Image from 'next/image'; import cron1 from '/public/nodes/cron-1.png'; import cron2 from '/public/nodes/cron-2.png'; import { Cards, Card } from 'nextra/components';

The Scheduled Cron Trigger node is a powerful tool within BuildShip that enables you to automate workflows based on scheduled time intervals. This trigger allows you to initiate workflows at specific times, or patterns, ensuring timely execution of your automation tasks.

Scheduled Cron Trigger

User Friendly Cron Triggers ⏰

BuildShip offers a 4 user-friendly cron triggers which let you schedule workflows to run at specific intervals, like every day, every hour, every month, and every week. No need to set up complex cron expressions, just choose the desired interval and time zone. Learn more:

<>![Every Day Cron Trigger](/assets/every-day.png) <>![Every Hour Cron Trigger](/assets/every-hour.png) <>![Every Month Cron Trigger](/assets/every-month.png) <>![Every Month Cron Trigger](/assets/every-week.png)

How to Use Scheduled Cron Trigger

The Scheduled Cron Trigger node comes with three essential fields that you need to configure:

  • Location: The GCP region where the trigger will be executed. This field is automatically filled based on the GCP region associated with your workspace.

  • Schedule: Set the schedule pattern using the cron syntax. This field determines the frequency and timing of your workflow execution. For example, */20 * * * * specifies an interval of 20 minutes.

Discover additional information about cron syntax and creating custom cron expressions [here](#understanding-the-cron-syntax).
  • Time Zone: Choose the desired time zone for your scheduled trigger. You can select from the list of existing time zones.

Understanding the Cron Syntax

CRON syntax is a widely used standard for scheduling tasks in various Unix-like operating systems. It defines a set of fields that specify when a task should be executed based on time intervals. Each field represents a unit of time, allowing users to define intricate scheduling patterns.

Cron Syntax

The CRON syntax consists of five fields, each separated by a space:

  1. Minute (0 - 59): Specifies the minute at which the task should run. A value of * indicates any minute, while 0 indicates the exact minute.

  2. Hour (0 - 23): Specifies the hour at which the task should run. A value of * indicates any hour, while 0 indicates midnight.

  3. Day of Month (1 - 31): Specifies the day of the month when the task should run. A value of * indicates any day, while specific numbers represent particular days.

  4. Month (1 - 12): Specifies the month when the task should run. A value of * indicates any month, while specific numbers represent particular months.

  5. Day of Week (0 - 6): Specifies the day of the week when the task should run. The values 0 and 7 often represent Sunday, 1 represents Monday, and so on.

The CRON syntax also supports special characters and shorthand notations:

  • */x: Represents every x interval. For example, */15 in the minutes field means every 15 minutes.
  • x-y: Represents a range of values. For example, 1-5 in the day of week field means Monday to Friday.
  • x,y,z: Represents a list of values. For example, 1,15 in the day of month field means the 1st and 15th day.
**EXAMPLE 1:** Suppose you want to schedule a task to run every day at 3:30 PM.

The CRON expression for this scenario would be: 30 15 * * *

  • Minute (30): The task should run at the 30th minute of the hour.
  • Hour (15): The task should run at the 15th hour, which is 3:00 PM in 24-hour format.
  • Day of Month (*): The task should run on any day of the month.
  • Month (*): The task should run in any month.
  • Day of Week (*): The task should run on any day of the week.
**EXAMPLE 2:** Suppose you want to schedule a task to run every weekday (Monday to Friday) at 9:00 AM.

The CRON expression for this scenario would be: 0 9 * * 1-5

  • Minute (0): The task should run at the 0th minute of the hour.
  • Hour (9): The task should run at the 9th hour, which is 9:00 AM.
  • Day of Month (*): The task should run on any day of the month.
  • Month (*): The task should run in any month.
  • Day of Week (1-5): The task should run on Monday to Friday.

Setting up the Scheduled Cron Trigger

To set up a Scheduled Cron Trigger within your BuildShip workflow, follow these steps:

Add Trigger Node

Create a new workflow or open an existing one. Click "Add Trigger" and select "Scheduled Cron" from the available trigger options.

Configure Fields

Configure the fields within the Scheduled Cron Trigger node. You can choose the desired GCP region, schedule pattern, and time zone for your trigger as given in the above sections.

**Use Cases for Scheduled Interval Trigger**
**Example 1: Daily Backup**

**CRON Expression**: `0 0 * * *`

**Description**: This expression triggers the workflow every day at midnight. It's perfect for automating daily backups of your data.

**Example 2: Weekly Reports**

**CRON Expression**: `0 8 * * 1`

**Description**: This expression triggers the workflow every Monday at 8:00 AM. It's great for generating weekly reports at the start of the workweek.