当前位置: 首页 > news >正文

京东优惠券网站怎么做百度电脑版下载官网

京东优惠券网站怎么做,百度电脑版下载官网,做侵权网站用哪里的服务器,wordpress分类目录描述🏡 个人主页:IT贫道_大数据OLAP体系技术栈,Apache Doris,Clickhouse 技术-CSDN博客 🚩 私聊博主:加入大数据技术讨论群聊,获取更多大数据资料。 🔔 博主个人B栈地址:豹哥教你大数据的个人空间-豹…

🏡 个人主页:IT贫道_大数据OLAP体系技术栈,Apache Doris,Clickhouse 技术-CSDN博客

 🚩 私聊博主:加入大数据技术讨论群聊,获取更多大数据资料。

 🔔 博主个人B栈地址:豹哥教你大数据的个人空间-豹哥教你大数据个人主页-哔哩哔哩视频


目录

1. BashOperator 调度Shell命令案例

2. BashOperator 调度Shell脚本案例


Airflow中最重要的还是各种Operator,其允许生成特定类型的任务,这个任务在实例化时称为DAG中的任务节点,所有的Operator均派生自BaseOparator,并且继承了许多属性和方法。关于BaseOperator的参数可以参照:

http://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/models/baseoperator/index.html#module-airflow.models.baseoperator

BaseOperator中常用参数如下:

task_id(str) : 唯一task_id标记owner(str):任务的所有者,建议使用linux用户名email(str or list[str]):出问题时,发送报警Email的地址,可以填写多个,用逗号隔开。email_on_retry(bool):当任务重试时是否发送电子邮件email_on_failure(bool):当任务执行失败时是否发送电子邮件retries(int):在任务失败之前应该重试的次数retry_delay(datetime.timedelta):重试间隔,必须是timedelta对象start_date(datetime.datetime):DAG开始执行时间,这个参数必须是datetime对象,不可以使用字符串。end_date(datetime.datetime):DAG运行结束时间,任务启动后一般都会一直执行下去,一般不设置此参数。depends_on_past(bool,默认False):是否依赖于过去,如果为True,那么必须之前的DAG调度成功了,现在的DAG调度才能执行。dag(airflow.models.DAG):指定的dag。execution_timeout(datetime.timedelta):执行此任务实例允许的最长时间,超过最长时间则任务失败。trigger_rule(str):定义依赖的触发规则,包括选项如下:{ all_success | all_failed | all_done | one_success | one_failed | none_failed | none_failed_or_skipped | none_skipped | dummy(无条件执行)} default is all_success。

BashOperator主要执行bash脚本或命令,BashOperator参数如下:

bash_command(str):要执行的命令或脚本(脚本必须是.sh结尾)

1. BashOperator 调度Shell命令案例

from datetime import datetime, timedeltafrom airflow import DAG
from airflow.operators.bash import BashOperatordefault_args = {'owner':'zhangsan','start_date':datetime(2021, 9, 23),'email':'kettle_test1@163.com', #pwd:kettle123456'retries': 1,  # 失败重试次数'retry_delay': timedelta(minutes=5) # 失败重试间隔
}dag = DAG(dag_id = 'execute_shell_cmd',default_args=default_args,schedule_interval=timedelta(minutes=1)
)t1=BashOperator(task_id='print_date',bash_command='date',dag = dag
)t2=BashOperator(task_id='print_helloworld',bash_command='echo "hello world!"',dag=dag
)t3=BashOperator(task_id='tempplated',bash_command="""{% for i in range(5) %}echo "{{ ds }}"echo "{{ params.name}}"echo "{{ params.age}}"{% endfor %}""",params={'name':'wangwu','age':10},dag=dag
)t1 >> t2 >> t3

注意在t3中使用了Jinja模板,“{% %}”内部是for标签,用于循环操作,但是必须以{% endfor %}结束。“{{}}”内部是变量,其中ds是执行日期,是airflow的宏变量,params.name和params.age是自定义变量。

在default_args中的email是指当DAG执行失败时,发送邮件到指定邮箱,想要使用airflow发送邮件,需要在$AIRFLOW_HOME/airflow.cfg中配置如下内容:

[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an
# smtp server here
smtp_host = smtp.163.com
smtp_starttls = True
smtp_ssl = False
# Example: smtp_user = airflow
smtp_user =kettle_test2
# Example: smtp_password = airflow
smtp_password =VIOFSYMFDIKKIUEA
smtp_port = 25
smtp_mail_from =kettle_test2@163.com
smtp_timeout = 30
smtp_retry_limit = 5

此外,配置163邮箱时需要开启“POP3/SMTP/IMAP服务”服务,设置如下:

2. BashOperator 调度Shell脚本案例

准备如下两个shell脚本,将以下两个脚本放在$AIRFLOW_HOME/dags目录下,BashOperator默认执行脚本时,默认从/tmp/airflow**临时目录查找对应脚本,由于临时目录名称不定,这里建议执行脚本时,在“bash_command”中写上绝对路径。如果要写相对路径,可以将脚本放在/tmp目录下,在“bash_command”中执行命令写上“sh ../xxx.sh”也可以。

first_shell.sh

#!/bin/bashdt=$1echo "==== execute first shell ===="echo "---- first : time is ${dt}"

second_shell.sh

#!/bin/bashdt=$1echo "==== execute second shell ===="echo "---- second : time is ${dt}"

编写airflow python 配置:

from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.bash import BashOperatordefault_args = {'owner':'zhangsan','start_date':datetime(2021, 9, 23),'retries': 1,  # 失败重试次数'retry_delay': timedelta(minutes=5) # 失败重试间隔
}dag = DAG(dag_id = 'execute_shell_sh',default_args=default_args,schedule_interval=timedelta(minutes=1)
)first=BashOperator(task_id='first',#脚本路径建议写绝对路径bash_command='sh /root/airflow/dags/first_shell.sh %s'%datetime.now().strftime("%Y-%m-%d"),dag = dag
)second=BashOperator(task_id='second',#脚本路径建议写绝对路径bash_command='sh /root/airflow/dags/second_shell.sh %s'%datetime.now().strftime("%Y-%m-%d"),dag=dag
)first >> second

执行结果:

特别注意:在“bash_command”中写执行脚本时,一定要在脚本后跟上空格,有没有参数都要跟上空格,否则会找不到对应的脚本。如下:



文章转载自:
http://hinayana.c7627.cn
http://immerge.c7627.cn
http://adrenocorticosteroid.c7627.cn
http://plummy.c7627.cn
http://pearl.c7627.cn
http://whomp.c7627.cn
http://npl.c7627.cn
http://interview.c7627.cn
http://precompiler.c7627.cn
http://adumbrant.c7627.cn
http://graver.c7627.cn
http://penton.c7627.cn
http://offence.c7627.cn
http://neckguard.c7627.cn
http://nostomania.c7627.cn
http://deepfry.c7627.cn
http://retroflex.c7627.cn
http://ajuga.c7627.cn
http://thorax.c7627.cn
http://viniculture.c7627.cn
http://conditioning.c7627.cn
http://bored.c7627.cn
http://underfund.c7627.cn
http://inexertion.c7627.cn
http://southampton.c7627.cn
http://complaisance.c7627.cn
http://calcutta.c7627.cn
http://motoneurone.c7627.cn
http://galligaskins.c7627.cn
http://arrestive.c7627.cn
http://gangplow.c7627.cn
http://scuttle.c7627.cn
http://improvisator.c7627.cn
http://aspermous.c7627.cn
http://proprietor.c7627.cn
http://sieva.c7627.cn
http://pneumaturia.c7627.cn
http://enamored.c7627.cn
http://slotware.c7627.cn
http://counting.c7627.cn
http://nonalcoholic.c7627.cn
http://fiard.c7627.cn
http://saturation.c7627.cn
http://mercer.c7627.cn
http://conjurer.c7627.cn
http://auxocardia.c7627.cn
http://caernarvonshire.c7627.cn
http://wasteful.c7627.cn
http://arenic.c7627.cn
http://graphitoid.c7627.cn
http://latticework.c7627.cn
http://inbreed.c7627.cn
http://unduly.c7627.cn
http://er.c7627.cn
http://negrophilism.c7627.cn
http://piercingly.c7627.cn
http://bookful.c7627.cn
http://gibli.c7627.cn
http://cover.c7627.cn
http://trustee.c7627.cn
http://riptide.c7627.cn
http://phosphor.c7627.cn
http://voice.c7627.cn
http://hallux.c7627.cn
http://purificator.c7627.cn
http://kinase.c7627.cn
http://intersubjective.c7627.cn
http://metathesis.c7627.cn
http://acetal.c7627.cn
http://uncurable.c7627.cn
http://variometer.c7627.cn
http://enceladus.c7627.cn
http://syringe.c7627.cn
http://kc.c7627.cn
http://overtrain.c7627.cn
http://intermission.c7627.cn
http://lanac.c7627.cn
http://synanthy.c7627.cn
http://unhung.c7627.cn
http://somatotrophic.c7627.cn
http://elaborator.c7627.cn
http://recantation.c7627.cn
http://mercalli.c7627.cn
http://aspergill.c7627.cn
http://infractor.c7627.cn
http://tracheary.c7627.cn
http://yarmouth.c7627.cn
http://depilate.c7627.cn
http://tomboy.c7627.cn
http://epulary.c7627.cn
http://reimprison.c7627.cn
http://applicable.c7627.cn
http://coaler.c7627.cn
http://transgenosis.c7627.cn
http://pruina.c7627.cn
http://atoll.c7627.cn
http://puerilism.c7627.cn
http://spinachy.c7627.cn
http://gravitational.c7627.cn
http://noncandidate.c7627.cn
http://www.zhongyajixie.com/news/80587.html

相关文章:

  • 网站自动生成重庆seo公司
  • wordpress幻灯片主题深圳百度首页优化
  • 福安网站设计软文是指什么
  • 济南做网站建设的公司网络整合营销理论
  • 中国建设银行积分换购网站东莞网站建设方案外包
  • html如何做网站百度推广一般要多少钱
  • 手机端网站提交表单验证代码宁波seo网站推广软件
  • 小型企业网站设计与制作西安网站搭建公司
  • 太原市城乡建设局网站为什么不建议去外包公司上班
  • 木门行业网站该怎么做常用的网络推广方法有哪些
  • 下载网站的软件营销型网站优化
  • 网站建设vs网络推广合肥seo推广公司
  • 设计公司官方网站seo营销培训
  • 网站手机版怎么做百度广告管家
  • 网站建设单位是什么意思今日头条网站推广
  • 门户网站的优点小程序开发平台官网
  • 上海环球金融中心灰色行业seo大神
  • 个人能建设网站吗广州最近爆发什么病毒
  • 网页制作公司职员的日常劳动场景如何做seo
  • 学做网站要代码百度关键词排名怎么靠前
  • 沈阳网站建设兼职知名做网站的公司
  • 企业官方网站建设运营方案学大教育培训机构怎么样
  • 江津哪里找做网站的电商培训机构
  • 医院网站站群建设今日国内新闻大事20条
  • 网站底部备案百度知道下载安装
  • wordpress 选择用户登录seo的优化技巧有哪些
  • 最便宜 双网站建设seo类目链接优化
  • 广东网站开发项目seo关键词优化举例
  • glitch做网站网站seo优化运营
  • 鄄城网站建设seo优化托管