Schedules - TypeScript SDK
The pages shows how to do the following:
How to Schedule a Workflow
Scheduling Workflows is a crucial aspect of any automation process, especially when dealing with time-sensitive tasks. By scheduling a Workflow, you can automate repetitive tasks, reduce the need for manual intervention, and ensure timely execution of your business processes
Use any of the following action to help Schedule a Workflow Execution and take control over your automation process.
How to Create a Scheduled Workflow
The create action enables you to create a new Schedule. When you create a new Schedule, a unique Schedule ID is generated, which you can use to reference the Schedule in other Schedule commands.
How to Backfill a Scheduled Workflow
The backfill action executes Actions ahead of their specified time range. This command is useful when you need to execute a missed or delayed Action, or when you want to test the Workflow before its scheduled time.
How to Delete a Scheduled Workflow
The delete action enables you to delete a Schedule. When you delete a Schedule, it does not affect any Workflows that were started by the Schedule.
How to Describe a Scheduled Workflow
The describe action shows the current Schedule configuration, including information about past, current, and future Workflow Runs. This command is helpful when you want to get a detailed view of the Schedule and its associated Workflow Runs.
How to List a Scheduled Workflow
The list action lists all the available Schedules. This command is useful when you want to view a list of all the Schedules and their respective Schedule IDs.
How to Pause a Scheduled Workflow
The pause action enables you to pause and unpause a Schedule. When you pause a Schedule, all the future Workflow Runs associated with the Schedule are temporarily stopped. This command is useful when you want to temporarily halt a Workflow due to maintenance or any other reason.
How to Trigger a Scheduled Workflow
The trigger action triggers an immediate action with a given Schedule. By default, this action is subject to the Overlap Policy of the Schedule. This command is helpful when you want to execute a Workflow outside of its scheduled time.
How to Update a Scheduled Workflow
The update action enables you to update an existing Schedule. This command is useful when you need to modify the Schedule's configuration, such as changing the start time, end time, or interval.
How to use Temporal Cron Jobs
We recommend using Schedules instead of Cron Jobs. Schedules were built to provide a better developer experience, including more configuration options and the ability to update or pause running Schedules.
A Temporal Cron Job is the series of Workflow Executions that occur when a Cron Schedule is provided in the call to spawn a Workflow Execution.
A Cron Schedule is provided as an option when the call to spawn a Workflow Execution is made.
You can set each Workflow to repeat on a schedule with the cronSchedule
option:
const handle = await client.workflow.start(scheduledWorkflow, {
// ...
cronSchedule: '* * * * *', // start every minute
});
Start Delay
How to use Start Delay
Use the startDelay
to schedule a Workflow Execution at a specific one-time future point rather than on a recurring schedule.
You may specify the startDelay
option on either the client.workflow.start()
or client.workflow.execute()
methods of a Workflow Client.
For example:
const handle = await client.workflow.start(someWorkflow, {
// ...
startDelay: '2 hours',
});