Build reliable cron schedules

Use schedules for recurring tasks, like a cron job every 5 minutes, a task that runs at 9.30am every other Monday, or even a task that runs just once a year.

Add schedules to your tasks either in code, or using our dashboard. These can be either simple or multi-tenant, depending on your needs.

Declarative schedules

Add schedules to your tasks which sync when you run dev or deploy

We recommend declarative tasks for internal jobs. They live directly in your code so are version controlled in Git.

Declarative schedules docs
export const secondScheduledTask = schedules.task({
id: "second-scheduled-task",
cron: {
// 5am every day Tokyo time
pattern: "0 5 * * *",
timezone: "Asia/Tokyo",
},
run: async (payload) => {},
});

If you specify a timezone we’ll automatically adjust for Daylight Saving Time for you.

Imperative schedules in the dashboard

Attach schedules to your tasks, using the dashboard

Create, activate, disable, edit and delete schedules in the dashboard without having to deploy any new code.

Imperative schedules dashboard docs

Use AI and natural language to easily create cron expressions for your schedules. No more having to manually figure out complicated cron syntax.

Imperative schedules in the SDK

Attach schedules to your tasks using our SDK

Allows you to easily add schedules for your tenants using externalId.

Imperative schedules in the SDK docs
const createdSchedule = await schedules.create({
// The id of the scheduled task you want to attach to.
task: firstScheduledTask.id,
// The schedule in cron format.
cron: "0 0 * * *",
// This is required, it prevents you from creating duplicate schedules.
// It will update the schedule if it already exists.
deduplicationKey: "my-deduplication-key",
});

Schedules are instantly created when schedules.create() is run. This is a powerful way of creating multi-tenant schedules for your users.

As someone who can never remember the right format for a cron job, I love the option to enter it in plain English and get it generated for me.

DomNeuner

Multi-tenant schedules

Advanced dynamic schedules for your individual users

Multi-tenant schedules allow you to configure dynamic schedules depending on your user’s behaviour with your product or service.

Multi-tenant schedules docs
Multi-tenant schedules mobile

Example schedules

import { schedules } from "@trigger.dev/sdk/v3"
export const syncAirtable = schedules.task({
id: "sync-airtable",
run: async ({ timestamp, lastTimestamp }) => {
await airtable<StoreItems>("Store items")
.select({
filterByFormula: encodeURIComponent(
`AND(LAST_MODIFIED_TIME() >= ${lastTimestamp},
LAST_MODIFIED_TIME() <= ${timestamp})`
),
})
.eachPage(
async (records, fetchNextPage) => {
for (const record of records) {
const result = await processItem(record.fields);
await db.storeItems.upsert(result.id, result);
}
// Repeat for the next page
fetchNextPage();
}
);
},
});

Ready to start building?

Build and deploy your first task in 3 minutes.

Get started now
,