正文

Airflow SSH operator example

(2024-04-29 16:27:10) 下一个

from airflow import DAG
from airflow.operators.ssh_operator import SSHOperator
from datetime import datetime

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2024, 4, 29),
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1
}

dag = DAG('ssh_example', default_args=default_args, schedule_interval=None)

task_ssh = SSHOperator(
    task_id='execute_ssh_command',
    ssh_conn_id='ssh_default',  # The name of the SSH connection to use, defined in Airflow Connections
    command='echo "Hello, remote server"',
    dag=dag
)

[ 打印 ]
阅读 ()评论 (0)
评论
目前还没有任何评论
登录后才可评论.