Cron
Workload for recurring tasks.
Description
With this workload, you can define recurring tasks for your application.
A Cron workload is initialized with a unique ID and the following options:
run function with the code that will be executed.
ts
import { Cron } from "@monolayer/sdk";
const reports = new Cron("reports", {
schedule: "* * * * *",
run: async () => {
// Do something;
},
});
export default reports;Important
Export only one Cron workload per file as the default export.
Development environment
You can trigger a Cron workload on demand with the trigger cron CLI command.
Test environment
This workload does not have a test environment.
However, you can test the run function of a Cron workload in your test suite.
:::
Examples
ts
import { Cron } from "@monolayer/sdk";
const reports = new Cron("reports", {
schedule: "* * * * *",
run: async () => {
// Do something;
},
});
export default reports;