Skip to main content

Temporal CLI batch command reference

Batch commands change multiple Workflow Executions by providing a List Filter and the type of Batch Job to execute. The List Filter identifies the Workflow Executions in the Batch Job; the Batch type determines what will happen to the Workflow Executions.

Which batch operations can be performed by the Temporal CLI?

There are three types of Batch Jobs:

  • Cancel: cancels the Workflow Executions specified by the List Filter.
  • Signal: sends a Signal to the Workflow Executions specified by the List Filter.
  • Terminate: terminates the Workflow Executions specified by the List Filter.

Batch operations can affect multiple Workflows simultaneously. Depending on your needs, you might want to send Signals to running Workflows, Cancel them, or even Terminate them entirely. Below are examples of how to use the Temporal CLI for each type of Batch operation.

These commands will directly impact the Workflows you target, so it's important to use them judiciously.

You can use the --query flag, which acts as List Filter, to filter the Workflow Executions to be affected by the Batch Job.

To Cancel Workflows:

temporal workflow cancel \
--query 'ExecutionStatus = "Running" AND WorkflowType="YourWorkflow"' \
--reason "Testing"

To Signal Workflows:

temporal workflow signal \
--workflow-id MyWorkflowId \
--name MySignal \
--input '{"Input": "As-JSON"}' \
--query 'ExecutionStatus = "Running" AND WorkflowType="YourWorkflow"' \
--reason "Testing"

To Terminate Workflows:

temporal workflow terminate \
--query 'ExecutionStatus = "Running" AND WorkflowType="YourWorkflow"' \
--reason "Testing"

A successfully started Batch job will return a Job ID. Use this Job ID to execute other actions on the Batch job.

list

The temporal batch list command returns all Batch jobs. Batch Jobs can be returned for an entire Cluster or a single Namespace.

temporal batch list --namespace=MyNamespace

Use the following options to change the behavior of this command.

describe

The temporal batch describe command shows the progress of an ongoing Batch job.

Pass a valid Job ID to return a Batch Job's information.

temporal batch describe --job-id=MyJobId

Use the following options to change the behavior of this command.

terminate

The temporal batch terminate command terminates a Batch job with the provided Job ID. For future reference, provide a reason for terminating the Batch Job.

temporal batch terminate --job-id=MyJobId --reason=JobReason

Use the following options to change the behavior of this command.