CLI Reference
This page provides a comprehensive reference for the Apache Airflow command-line interface (CLI). The Airflow CLI is a powerful tool for managing and interacting with your Airflow environment.
Core Commands
These are the fundamental commands for interacting with Airflow.
airflow version
Prints the installed Airflow version.
airflow help [COMMAND]
Shows a list of available commands or help for a specific command.
$ airflow help
$ airflow dags --help
airflow config list
Lists all configuration parameters and their values.
airflow config get-value [SECTION] [KEY]
Gets a specific configuration value.
$ airflow config get-value core executor
DAG Processing
Commands related to the DAG processing pipeline.
airflow dags list-runs [DAG_ID]
List all DAG runs for a specific DAG.
airflow dags trigger [DAG_ID]
Trigger a DAG run.
$ airflow dags trigger my_dag_id --conf '{"key": "value"}'
airflow dags list
List all available DAGs.
airflow dags state [DAG_ID] [EXECUTION_DATE]
Get the state of a DAG run.
DAGs
Commands for managing DAGs.
airflow dags import-json [JSON_FILE]
Import DAGs from a JSON file.
airflow dags list-task-instances [DAG_ID] [EXECUTION_DATE]
List all task instances for a specific DAG run.
airflow dags failed [DAG_ID] [EXECUTION_DATE]
Mark a DAG run as failed.
Database
Commands for managing the Airflow metadata database.
airflow db init
Initialize the Airflow metadata database.
airflow db upgrade
Upgrade the Airflow metadata database to the latest schema version.
airflow db migrate
Run database migrations.
airflow db check
Check the database for consistency.
airflow db reset
Reset the database to an empty state (use with caution!).
Variables
Commands for managing Airflow variables.
airflow variables list
List all Airflow variables.
airflow variables get [KEY]
Get the value of a specific variable.
$ airflow variables get my_variable
airflow variables set [KEY] [VALUE]
Set the value of a variable.
$ airflow variables set my_variable "my_value"
airflow variables delete [KEY]
Delete a variable.
airflow variables import [FILE]
Import variables from a JSON file.
airflow variables export [FILE]
Export variables to a JSON file.
Connections
Commands for managing Airflow connections.
airflow connections list
List all Airflow connections.
airflow connections add [CONN_ID] --conn-type [CONN_TYPE] ...
Add a new connection.
$ airflow connections add my_postgres_conn --conn-type postgresql --conn-host localhost --conn-login user --conn-password pass --conn-schema public
airflow connections delete [CONN_ID]
Delete a connection.
airflow connections export [FILE]
Export connections to a JSON file.
airflow connections import [FILE]
Import connections from a JSON file.
Pools
Commands for managing Airflow pools.
airflow pools list
List all Airflow pools.
airflow pools set [POOL_NAME] [SLOT_COUNT] [DESCRIPTION]
Set or update a pool.
$ airflow pools set my_pool 5 "A custom pool for limiting parallel tasks"
airflow pools delete [POOL_NAME]
Delete a pool.
Users
Commands for managing Airflow users (requires RBAC to be enabled).
airflow users list
List all Airflow users.
airflow users create --username [USERNAME] --firstname [FIRSTNAME] --lastname [LASTNAME] --role [ROLE] --email [EMAIL]
Create a new user.
$ airflow users create --username admin --firstname Admin --lastname User --role Admin --email admin@example.com
airflow users delete --username [USERNAME]
Delete a user.
Plugins
Commands for managing Airflow plugins.
airflow plugins list
List all installed plugins.
Kubernetes
Commands related to Airflow on Kubernetes.
airflow kubernetes create-connection --name [CONN_NAME] --cluster-context [CONTEXT] --namespace [NAMESPACE]
Create a Kubernetes connection.
Celery
Commands for managing Airflow's Celery executor.
airflow celery worker status
Check the status of Celery workers.
Local Cluster
Commands for running Airflow in a local cluster mode.
airflow local create-dag-folder-symlinks
Create symlinks for DAG folders.
airflow local start --all
Start all Airflow components locally.
airflow local start scheduler webserver
Start specific Airflow components locally.
airflow local stop --all
Stop all Airflow components locally.
Providers
Commands for managing Airflow providers.
airflow providers list
List all installed providers.
airflow providers list-extras [PROVIDER_NAME]
List extra dependencies for a provider.
Tasks
Commands for managing individual tasks.
airflow tasks list [DAG_ID]
List all tasks in a DAG.
airflow tasks test [DAG_ID] [TASK_ID] [EXECUTION_DATE]
Run a task instance in test mode.
$ airflow tasks test my_dag_id my_task_id 2023-01-01
airflow tasks state [DAG_ID] [TASK_ID] [EXECUTION_DATE]
Get the state of a task instance.
airflow tasks clear [DAG_ID] [--task-regex TASK_REGEX] [--start-date START_DATE] [--end-date END_DATE]
Clear task instances.
$ airflow tasks clear my_dag_id --start-date 2023-01-01 --end-date 2023-01-05
Scheduler
Commands for the Airflow scheduler.
airflow scheduler
Start the Airflow scheduler.
Webserver
Commands for the Airflow webserver.
airflow webserver
Start the Airflow webserver.
Configuration
Commands for accessing Airflow configuration.
airflow config get [SECTION] [KEY]
Get a specific configuration value.
airflow config section --help
View help for section-specific commands.
Plugins Management
Commands related to managing Airflow plugins.
airflow plugins generate-plugin [PLUGIN_NAME] --output-dir [DIR]
Generate a boilerplate plugin.
Other Commands
Miscellaneous useful commands.
airflow rotate-key
Rotate the Fernet key used for encrypting connections.
airflow jobs list
List all running jobs.
For detailed information about each command and its options, use the airflow [COMMAND] --help syntax.