Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How do I send a mail in Oozie by mentioning the Start Time and End Time in the mail body ?

avatar
Contributor

I need to capture the job status, Start time and End Time of the work and mail it using the mail action in Oozie.

1 ACCEPTED SOLUTION

avatar
Master Guru
@Sai ram

There are no direct variables to get start time and end time in oozie. '${timestamp()}' can return current timestamp in UTC. I would suggest to use another approach, start and end your oozie workflow with an email action, in this way, you will receive 2 emails, one when your oozie workflow will start and another when your job will end. If you want more better solution then I would suggest to write a script which will fetch start time, end time from oozie commands or from oozie database and have script to send an email for multiple jobs at once in a tabular format.

Hope this information helps.

View solution in original post

7 REPLIES 7

avatar
Contributor

avatar
Master Guru

You can do this by setting a parameter with start and end time.

For example

<property>
<name>the_timestamp</name>
<value>${timestamp()}</value>
<property>

Set that to start time and another to end time when you hit a action.

For information on oozie emails here:

https://oozie.apache.org/docs/3.3.0/DG_EmailActionExtension.html

avatar
Contributor

Thanks, but I am not looking for timestamp, I need the job status and execution time. In short, I need to mail the output of this command, oozie job -oozie {SERVER_DETAILS} -info ${job_id}

avatar
Master Guru
@Sai ram

There are no direct variables to get start time and end time in oozie. '${timestamp()}' can return current timestamp in UTC. I would suggest to use another approach, start and end your oozie workflow with an email action, in this way, you will receive 2 emails, one when your oozie workflow will start and another when your job will end. If you want more better solution then I would suggest to write a script which will fetch start time, end time from oozie commands or from oozie database and have script to send an email for multiple jobs at once in a tabular format.

Hope this information helps.

avatar
Contributor

@Kuldeep Kulkarni Is there a way where I can execute this command inside the mail action in oozie ?

oozie job -oozie {SERVER_DETAILS} -info ${job_id}

avatar
Master Guru

@Sai ram - No you cann't. But you can write a shell action and in shell script you can execute this command as well as mail command

avatar
Contributor

I need to capture the highlighted fields in the screenshot.

6056-capture.png