Skip to content

workloads / main / Cron

Class: Cron

Workload for recurring tasks.

A Cron workload is initialized with a unique id and the following options:

  • schedule in unix-cron format to specify when it should run.

  • run function with the code that will be executed.

Example

ts
import { Cron } from "@monolayer/sdk";

const reports = new Cron("reports", {
  schedule: "* * * * *",
  run: async () => {
    // Do something;
  },
});

export default reports;

Extends

Constructors

new Cron()

ts
new Cron(id, options): Cron

Parameters

ParameterTypeDescription

id

string

Unique ID

options

CronOptions

Returns

Cron

Overrides

StatelessWorkload.constructor

Properties

PropertyModifierTypeDescription
idpublicstringUnique ID
optionspublicCronOptions-
runpublic() => Promise<void>-
schedulepublicstring-