Getting current time in oozie workflow

DMA picture DMA · Feb 13, 2014 · Viewed 9.2k times · Source

I've a use case where I need to pass the current date from oozie workflow to pig script. I know that I can get the current date from pig, but my condition is different where in I've to pass it from oozie after an action is complete. Any idea how to achieve this?

And also I've a coordinator job, which will execute for every hour. So how to pass the coordinator execution date to the workflow?

Answer

Suvarna Pattayil picture Suvarna Pattayil · Feb 13, 2014

I've to pass it from oozie after an action is complete. Any idea how to achieve this?

You can use Oozie WL Function String timestamp() From the manpage,

It returns the UTC current date and time in W3C format down to the second (YYYY-MM-DDThh:mm:ss.sZ). I.e.: 1997-07-16T19:20:30.45Z

You can use this as a property,

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

Also, if your action is a Shell Action you can echo the time from within the code and use capture-output to use it further.

I don't know how to handle the second query. All I know is the properties file of the co-ordinator is used by the workflow,