This has been deprecated in favor of DynamicSchedule.register

Parameters

keyrequired
string

Should be a stable and unique key inside the run(). See resumability for more information.

dynamicSchedulerequired
DynamicSchedule

A DynamicSchedule that will trigger any Jobs it’s attached to on a regular interval.

idrequired
string

A unique id for the schedule. This is used to identify and unregister the schedule later.

optionsrequired
object

An object containing options about the interval.

cronrequired
string

A CRON expression that defines the schedule. A useful tool when writing CRON expressions is crontab guru. Note that the timezone used is UTC.

Returns

A Promise that resolves to an object with the following fields:

idrequired
string

A unique id for the interval. This is used to identify and unregister the interval later.

metadatarequired
any

Any additional metadata about the interval.

accountIdrequired
string

This will be used by the Trigger.dev Connect feature, which is coming soon.

schedulerequired
object
typerequired
string

The type of schedule. This will always be “cron”.

optionsrequired
object

An object containing options about the CRON schedule.

cronrequired
string

The registered CRON expression.

metadatarequired
any

Any additional metadata about the interval.

client.defineJob({
id: "my-job",
name: "My job",
version: "0.1.1",
trigger: eventTrigger({
  name: "dynamic.cron",
  schema: z.object({
    id: z.string(),
    cron: z.string(),
  }),
}),
run: async (payload, io, ctx) => {
  //registers a DynamicSchedule with a CRON expression 
  await io.registerCron("register-cron", dynamicSchedule, payload.id, {
    cron: payload.cron,
  });
},
});