client.defineJob({
  id: "scheduled-job-1",
  name: "Scheduled Job 1",
  version: "0.1.1",
  // 9am every day
  trigger: cronTrigger({
    cron: "0 9 * * *",
  }),
  run: async (payload, io, ctx) => {
    await io.logger.info("Received the scheduled event", {
      payload,
    });

    return { foo: "bar" };
  },
});

Development

Scheduled Triggers do not trigger Jobs in the DEV Environment. When you're working locally you should use the Test feature to trigger any scheduled Jobs.

CRON expressions

CRON expressions are strings that define when something should happen.

Some examples:

  • "0 0 * * *": will run the Job every day at 12:00am UTC.
  • "30 14 * * 1": will run the Job every Monday at 2:30pm UTC.

A useful tool when writing CRON expressions is crontab guru.

Parameters

options
object
required
cron
string
required

A CRON expression that defines the schedule. Note that the timezone used is always UTC.