deprecated
  • orbs-v3 overview
  • orbs-vm
    • Introduction
    • Get started
    • Dockerfile
      • Working Directory
      • Entry point
      • Health check
    • Status
    • Deployment
  • orbs-lambda
    • Introduction
    • Getting Started
    • Supported Networks
    • Project Structure
    • Lambda Triggers
      • OnSchedule
      • onBlocks
      • onEvent
      • Subscribing To Triggers
    • Writing Your Lambda Function
    • Test And Run Locally
    • Paying For Your Transactions
    • Submit Your Lambda
Powered by GitBook
On this page
  • Cron Expression
  • "Every" notation
  1. orbs-lambda
  2. Lambda Triggers

OnSchedule

PreviousLambda TriggersNextonBlocks

Last updated 2 years ago

This allows you to trigger your task based on a predefined schedule, either a cron expression or an "every x" notation.The interface is as follows:

engine.onSchedule(
    fn, // function to execute
    schedule, // cron expression / every x minutes/hours/days
    network, // string representation of one of the supported networks
    config // key:value object
)

Cron Expression

Standard cron expression in UTC timezone.

Cron expression utilizes the following format:

 *    *    *    *    *
┬    ┬    ┬    ┬    ┬
│    │    │    │    |
│    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
│    │    │    └───── month (1 - 12)
│    │    └────────── day of month (1 - 31)
│    └─────────────── hour (0 - 23)
└──────────────────── minute (0 - 59)

Examples with the cron format:

42 * * * * : Execute when the minute is 42 (e.g. 19:42, 20:42, etc.).

0 0 * * 1 : Execute at 00:00 on Monday

Unsupported Cron Features

Currently, W (nearest weekday) and L (last day of month/week) are not supported. Most other features supported by popular cron implementations should work seamlessly, including # (nth weekday of the month).

"Every" notation

If you don't like writing cron expressions and prefer to configure your job to run every nth minute/hour/day. The starting time used as a reference is the first minute of the hour / first hour of the day / first day of the month, respectively.

(TODO)

Format: [number]m|h|d

Examples:

"5m" = every 5th minute of the hour, starting from xx:00 (e.g. 04:00, 04:05, 04:10...)

"3h" = every 3rd hour, starting from 00:00. (e.g. 00:00, 03:00, 06:00...)

"7d" = At 00:00 on every 7th day-of-month, starting on the 1st (e.g. 2022-09-01 00:00:00, 2022-09-08 00:00:00, 2022-09-15 00:00:00, 2022-09-22 00:00:00, 2022-09-29 00:00:00, 2022-10-01 00:00:00)

is used to parse crontab instructions.

More on cron
cron-parser