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" };
  },
});

These are the docs for Trigger.dev v2 which will be deprecated on January 31st, 2025. You probably want the v3 docs.

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
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" };
  },
});