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]
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]
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]
airflow dags trigger <dag_id>
airflow dags trigger <dag_id> [options]
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>
airflow dags unpause <dag_id>
airflow dags unpause <dag_id>
airflow dags delete <dag_id>
airflow dags delete <dag_id>
Tasks
Commands related to managing tasks within DAGs.
airflow tasks list <dag_id>
airflow tasks list <dag_id> [options]
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]
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]
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>
Connections
Commands related to managing Airflow connections.
airflow connections list
airflow connections list [options]
Options:
--conn-type CONN_TYPE: Filter by connection type.
airflow connections add <conn_id>
airflow connections add <conn_id> [options]
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>
Variables
Commands related to managing Airflow variables.
airflow variables list
airflow variables list
airflow variables get <key>
airflow variables get <key> [options]
Options:
--default DEFAULT: Default value to return if variable is not found.
airflow variables set <key> <value>
airflow variables set <key> <value>
airflow variables delete <key>
airflow variables delete <key>
Providers
Commands related to managing Airflow providers.
airflow providers list
airflow providers list
Webserver
Commands related to starting and managing the Airflow webserver.
airflow webserver
airflow webserver [options]
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]
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.