-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea80312
commit 3e9bf86
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |