Manually triggers an asynchronous single run of a scheduled task (either a standalone task or the root task in a DAG (directed acyclic graph) of tasks) independent of the schedule defined for the task.

In this Topic:

## Syntax¶

EXECUTE TASK <name>


## Parameters¶

name

Identifier for the standalone task or root task to run. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

## Usage Notes¶

• Executing a task requires either the OWNERSHIP or OPERATE privilege on the task.

When the EXECUTE TASK command triggers a task run, Snowflake verifies that the role with the OWNERSHIP privilege on the task also has the USAGE privilege on the warehouse assigned to the task, as well as the global EXECUTE TASK privilege; if not, an error is produced.

• The SQL command can only execute a standalone task or the root task in a DAG. If a child task is input, the command returns a user error.

• A suspended root task is run without resuming the task; there is no need to explicitly resume the root task before you execute this SQL command. However, EXECUTE TASK does not automatically resume child tasks in the DAG. The command skips any child tasks that are suspended.

To recursively resume all dependent tasks tied to a root task in a DAG, query the SYSTEM\$TASK_DEPENDENTS_ENABLE function rather than enabling each task individually (using ALTER TASK … RESUME).

As a best practice when testing new or modified DAGs, set the root task to run on its intended production schedule but leave it in a suspended state. When you have tested the DAG successfully, resume the root task. Note that you must resume any suspended child tasks in the DAG for testing; otherwise, they are skipped during runs of the DAG.

• If the root task is currently running (i.e. in an EXECUTING state in the TASK_HISTORY output), the EXECUTE TASK command schedules another run of the task to start immediately after the current run is completed.

• If the root task is currently scheduled (i.e. in a SCHEDULED state in the TASK_HISTORY output), the scheduled run is replaced with the requested run as usual, with the current timestamp as the scheduled time. However, if the scheduled time has passed (but the task has not yet transitioned to an EXECUTING state), then the scheduled run occurs as usual. That is, the scheduled run is not replaced with the requested run.

• The ALLOW_OVERLAPPING_EXECUTION parameter set on a root task determines whether overlapping instances of the DAG are allowed. The behavior of requested task runs differs depending on the parameter value:

Manually trigger a run of a task named mytask:
EXECUTE TASK mytask;