A task that is triggered on a recurring schedule using cron syntax.
timestamp
- the time the task was scheduled to run, as a UTC date.lastTimestamp
- the time the task was last run, as a UTC date.timezone
- the timezone the schedule was registered with, defaults to “UTC”. In IANA format, e.g. “America/New_York”.scheduleId
- the id of the schedule that triggered the taskexternalId
- the external id you (optionally) provided when creating the scheduleupcoming
- the next 5 times the task is scheduled to runschedules.task
. They sync when you run the dev command or deploy.schedules.create()
.cron
property to your schedules.task()
. This property is optional and is only used if you want to add a declarative schedule to your task:
cron
property it will be updated when you run these commands. You can view your schedules on the Schedules page in the dashboard.
schedules.task
. You can do this in the Schedules page in the dashboard by just pressing the “New schedule” button, or you can use the SDK to create schedules.
The advantage of imperative schedules is that they can be created dynamically, for example, you could create a schedule for each user in your database. They can also be activated, disabled, edited, and deleted without deploying new code by using the SDK or dashboard.
To use imperative schedules you need to do two things:
schedules.task()
.Go to the Schedules page
Create your schedule
Name | Description |
---|---|
Task | The id of the task you want to attach to. |
Cron pattern | The schedule in cron format. |
Timezone | The timezone the schedule will run in. Defaults to “UTC” |
External id | An optional external id, usually you’d use a userId. |
Deduplication key | An optional deduplication key. If you pass the same value, it will update rather than create. |
Environments | The environments this schedule will run in. |
schedules.create()
to create a schedule from your code. Here’s the simplest possible example:
task
id must be a task that you defined using schedules.task()
.task
, cron
, and externalId
but only one with the same deduplicationKey
.
This means you can have thousands of schedules attached to a single task, but only one schedule per deduplicationKey
. Here’s an example with all the options:
externalId
you can have schedules for your users. This is useful for things like reminders, where you want to have a schedule for each user.
A reminder task:
scheduleId
will always come through as sched_1234
to the run.
Go to the Test page
Create your schedule