Skip to content

Instantly share code, notes, and snippets.

@yuyou
Created April 19, 2016 11:13
Show Gist options
  • Save yuyou/baa73df674d1dbcbc14d35b1fc293415 to your computer and use it in GitHub Desktop.
Save yuyou/baa73df674d1dbcbc14d35b1fc293415 to your computer and use it in GitHub Desktop.
A test Airflow dag to show the monthly "schedule_interval".
from airflow.operators import BashOperator
from airflow.models import DAG
from datetime import datetime, timedelta
args = {
'start_date': datetime.utcnow(),
'owner': 'airflow',
}
one_month_ago = datetime.combine(datetime.today() - timedelta(30),
datetime.min.time())
dag = DAG(
dag_id='hello',
default_args=args,
schedule_interval="@monthly")
#schedule_interval=None)
bash_task = BashOperator(
task_id="bash_task",
bash_command='echo "hello world"',
dag=dag)
@yuyou
Copy link
Author

yuyou commented Apr 19, 2016

To run this dag, you could use "backfill" to test it, for example, 4 runs from 2016-01-01 to 2016-04-01.
airflow backfill hello -s 2016-01-01 -e 2016-04-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment