我使用oozie
發送帶附件的電子郵件。我正在做如下。根據oozie電子郵件附件中的日期行爲傳遞變量
<workflow-app name="Email" xmlns="uri:oozie:workflow:0.5">
<start to="email-0fdf"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="email-0fdf">
<email xmlns="uri:oozie:email-action:0.2">
<to>[email protected]</to>
<subject>job success</subject>
<content_type>text/plain</content_type>
<attachment>/user/XXXX/logs/2017-05-03/exec.log</attachment>
</email>
<ok to="End"/>
<error to="Kill"/>
</action>
<end name="End"/>
</workflow-app>
現在在<attachment>/user/XXXX/logs/2017-05-03/exec.log</attachment>
附近的工作流程中日期總是變化。
我怎樣才能傳遞變量,當工作流程被調用,然後我想發送該特定的一天的附件。
已編輯的問題。
我的shell腳本:
#!/bin/bash
TIMESTAMP=`date "+%Y-%m-%d"`
path=/user/$USER/logging/${TIMESTAMP}/status/${TIMESTAMP}.fail_log
path1=/user/$USER/logging/`date -d "-1 days" '+%Y-%m-%d'`/status/`date -d "-1 days" '+%Y-%m-%d'`.fail_log
echo filePath=$path
echo filePath1=$path1
我的新工作流程:
<workflow-app name="My_Workflow" xmlns="uri:oozie:workflow:0.5">
<start to="shell-05e6"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-05e6">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>shell.sh</exec>
<file>/user/xxxxx/oozie/email/lib/shell.sh#shell.sh</file>
<capture-output/>
</shell>
<ok to="email-66c2"/>
<error to="Kill"/>
</action>
<action name="email-66c2">
<email xmlns="uri:oozie:email-action:0.2">
<to>[email protected]</to>
<subject>job status</subject>
<body>job status ${wf:actionData('shell-05e6')['filePath']}</body>
<content_type>text/plain</content_type>
<attachment>${wf:actionData('shell-05e6')['filePath']},${wf:actionData('shell-05e6')['filePath1']}</attachment>
</email>
<ok to="End"/>
<error to="Kill"/>
</action>
<end name="End"/>
現在,如果在該位置的一個沒有文件說,無論是filepath
或filepath1
,則電子郵件操作失敗。
我要的是不論文件是否存在或不是我想要的電子郵件的行動是成功的
讓我知道你最喜歡哪種方法。 –