Apache Airflow CLI Reference

The Apache Airflow command-line interface (CLI) is a powerful tool that allows you to interact with your Airflow deployment, manage DAGs, tasks, connections, variables, and more. This document provides a comprehensive reference to the available CLI commands and their options.

General Usage

The basic syntax for Airflow CLI commands is:

airflow [global options] command [command options] [arguments]

Global Options

These options can be used with any Airflow CLI command:

Option Description
--help, -h Show the help message and exit.
--version, -v Show the Airflow version and exit.
--verbose, -V Enable verbose logging.
--debug, -d Enable debug logging.
--quiet, -q Suppress output messages.

Core Commands

DAGs

Commands related to managing Directed Acyclic Graphs (DAGs).

airflow dags list

airflow dags list [options]
Lists all DAGs in your Airflow deployment.
Options:
  • --subdir SUBDIR: Specify a subdirectory to scan for DAGs.
  • --include-paused: Include paused DAGs in the listing.

airflow dags show <dag_id>

airflow dags show <dag_id> [options]
Displays the structure of a specific DAG.
Options:
  • --tree: Display the DAG as a tree.
  • --graph: Display the DAG as a graph (requires Graphviz).

airflow dags state <dag_id> [<task_id>]

airflow dags state <dag_id> [<task_id>] [options]
Get the state of a DAG or a specific task within a DAG.

airflow dags trigger <dag_id>

airflow dags trigger <dag_id> [options]
Triggers a DAG run.
Options:
  • --conf <json>: JSON string for configuration.
  • --run-id <run_id>: Specify a custom run ID.

airflow dags pause <dag_id>

airflow dags pause <dag_id>
Pauses a DAG.

airflow dags unpause <dag_id>

airflow dags unpause <dag_id>
Unpauses a DAG.

airflow dags delete <dag_id>

airflow dags delete <dag_id>
Deletes a DAG and its associated task instances.

Tasks

Commands related to managing tasks within DAGs.

airflow tasks list <dag_id>

airflow tasks list <dag_id> [options]
Lists all tasks within a specified DAG.
Options:
  • --tree: Display tasks as a tree.

airflow tasks run <dag_id> <task_id> <execution_date>

airflow tasks run <dag_id> <task_id> <execution_date> [options]
Runs a specific task instance.
Options:
  • --local: Run task locally without the scheduler.
  • --ignore-all-deps: Ignore all dependencies.
  • --ignore-depends-on-past: Ignore depends_on_past dependencies.
  • --ignore-dependencies: Ignore all dependencies.
  • --force: Force run the task, even if it has succeeded.

airflow tasks clear <dag_id>

airflow tasks clear <dag_id> [options]
Clears task instances for a DAG or a specific task.
Options:
  • --start-date START_DATE: Start date for clearing (inclusive).
  • --end-date END_DATE: End date for clearing (inclusive).
  • --task-regex TASK_REGEX: Regex to filter tasks to clear.
  • --dag-run-id DAG_RUN_ID: Clear only for a specific DAG run.

airflow tasks state <dag_id> <task_id> <execution_date>

airflow tasks state <dag_id> <task_id> <execution_date>
Get the state of a specific task instance.

Connections

Commands related to managing Airflow connections.

airflow connections list

airflow connections list [options]
Lists all connections.
Options:
  • --conn-type CONN_TYPE: Filter by connection type.

airflow connections add <conn_id>

airflow connections add <conn_id> [options]
Adds a new connection. Prompts for details if not provided.
Options:
  • --conn-type CONN_TYPE: Type of connection (e.g., http, postgres).
  • --conn-host HOST: Hostname.
  • --conn-login LOGIN: Username.
  • --conn-password PASSWORD: Password.
  • --conn-schema SCHEMA: Schema name.
  • --conn-port PORT: Port number.
  • --conn-extra EXTRA_JSON: Extra JSON parameters.

airflow connections delete <conn_id>

airflow connections delete <conn_id>
Deletes a connection.

Variables

Commands related to managing Airflow variables.

airflow variables list

airflow variables list
Lists all Airflow variables.

airflow variables get <key>

airflow variables get <key> [options]
Gets the value of a variable.
Options:
  • --default DEFAULT: Default value to return if variable is not found.

airflow variables set <key> <value>

airflow variables set <key> <value>
Sets the value of a variable.

airflow variables delete <key>

airflow variables delete <key>
Deletes a variable.

Providers

Commands related to managing Airflow providers.

airflow providers list

airflow providers list
Lists all installed Airflow providers.

Webserver

Commands related to starting and managing the Airflow webserver.

airflow webserver

airflow webserver [options]
Starts the Airflow webserver.
Options:
  • --port PORT: Port to run the webserver on. Defaults to 8080.
  • --host HOST: Host to run the webserver on. Defaults to localhost.

Scheduler

Commands related to starting and managing the Airflow scheduler.

airflow scheduler

airflow scheduler [options]
Starts the Airflow scheduler.
Options:
  • --dag-id DAG_ID: Specify a DAG to schedule.
  • --local: Run scheduler in local mode.

This reference covers the most common CLI commands. For more detailed information on specific commands or less frequently used options, please refer to the official Airflow CLI documentation.