Skip to content

Commit

Permalink
added DAG demo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanRattan committed Mar 10, 2024
1 parent ea80312 commit 3e9bf86
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions programming/airflow/dags/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


from airflow.operators.python import PythonOperator
from airflow.operators.bash import BashOperator

from datetime import datetime, timedelta
from airflow import DAG


savepath_txt = 'log.txt'

bash_cp_cmd = 'cp -r /airflow/*.py /airflow/test/'

default_args = {'owner': 'ishan',
'start_date': datetime(2024, 3, 9)}


def save_time_stamp():
with open(savepath_txt, 'a') as outfile:
outfile.write(str(datetime.now()) + '\n')

dag = DAG('cp_pyfiles_save_ts',
default_args=default_args,
description="copy files from source to dest",
schedule_interval=timedelta(minutes=2),
catchup=False)

copy_files_task = BashOperator(task_id='copy_files_task',
bash_command=bash_cp_cmd,
dag=dag)

0 comments on commit 3e9bf86

Please sign in to comment.