Pass date from airflow dag to a task

39 views Asked by At

I am using SSHOperator in airflow dag ( I am using AWS MWAA service for airflow). It is executing a shell script. I need to pass current date and time in format %Y-%m-%dT%H:%M:%S.%f%z to the script.

I do not have Pendulam package available in my airflow so I am trying to use datetime. I tried passing the date using datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f%z') but it fails.

I also tried to print it directly in dag ( like below) but this doesn't work either.

print(datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f%z'))

Can someone please suggest how to pass current date in this format to shell script.

0

There are 0 answers