在Oozie中调用Shell脚本:如何基于脚本中不同的返回值使用决策节点 [英] Calling shell script in Oozie: how to use decision node on base of different return values from the script

查看:292
本文介绍了在Oozie中调用Shell脚本:如何基于脚本中不同的返回值使用决策节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Oozie调用Shell脚本.根据被调用的Shell脚本的退出值,Oozie可以轻松选择OK或ERROR节点,但是如果Shell以0或1之外的其他值退出怎么办? Oozie可以基于被调用的Shell脚本的退出值使用决策节点切换到不同的节点吗?

I am currently using Oozie to call Shell script. On base of exit value of the called shell script, Oozie can easily choose OK or ERROR node, but what if Shell exits with other values than 0 or 1? can Oozie use the decision node to switch to different nodes on base of the exit value of the called Shell script?

我正在考虑使用EL函数,但不知道为什么EL函数会获取以前调用的Shell脚本的退出代码

I am thinking about using EL function, but do not know whyc EL function get the exit code of previously called Shell script

推荐答案

  1. 确保对于关键错误(不可恢复,请转到 kill ),shell以非零值退出;对于成功或应用程序错误,请以零退出(继续工作流以检查状态)
  2. 确保外壳程序将"strong"状态代码以外的任何内容都发送给StdOut,否则,您可能会在第4步中爆炸HashMap.
  3. 使用Java属性语法返回软"状态报告,例如echo "status.rc=0" ; echo "status.message=so far, so good"
  4. 在Shell Action中设置
  5. set <capture_output/>选项,以便Oozie在HashMap(键/值)中检索您的状态报告
  6. 将工作流分支到决策"节点,检查显示软状态的值(使用wf:actionData() EL函数),并相应地分支
  1. make sure that the shell exits with non-zero for critical errors (irrecoverable, go to kill) and zero for success or app errors (continue workflow to check status)
  2. make sure that the shell sends nothing to StdOut except your "soft" status code, otherwise you might blast the HashMap at step 4
  3. return your "soft" status report using Java properties syntax e.g. echo "status.rc=0" ; echo "status.message=so far, so good"
  4. set <capture_output/> option in the Shell Action so that Oozie retrieves your status report in a HashMap (key/value)
  5. branch the Workflow to a Decision node, check the value that shows the soft status (using wf:actionData() EL function), and branch accordingly

这篇关于在Oozie中调用Shell脚本:如何基于脚本中不同的返回值使用决策节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆