Useful Oozie CLI commands

oozie cli

In this post, I’m wrote about some useful Oozie cli commands.

In my company, we use Amazon EMR for our data platform and Spark for data processing jobs. Since most of our jobs are need to be run every day, we scheduled them to run through Apache oozie (comes with EMR).

Though the oozie interface (Hue oozie) is easy to use, oozie cli commands are very handy. Especially when you have to check/analyse the failed workflows, generate a report of failures, etc. In this post, I’ve listed some of the oozie cli commands which I found useful.

For starters:

Oozie workflow is a defined sequence of actions written in xml. The actions can be simple shell script, hive, spark, map reduce jobs.

Oozie coordinator is a program that triggers workflow jobs when certain conditions are met, commonly time frequency and other external events. You can schedule a coordinator to run workflows on a specific time every hour or day or week or month, configurable in a cron syntax.

The below commands can only be executed in the oozie server node, i.e master node in EMR.

 

#Print oozie workflows details
$ oozie jobs  
(By default, this command prints last 100 workflows)

#Print all coordinators details
$ oozie jobs -jobtype coordinator

#Print running coordinators details
$ oozie jobs -jobtype coordinator -filter status=RUNNING
(Options: status=KILLED, status=SUSPENDED)

#Print last 500 workflows
$ oozie jobs -len 500
(Returns last 500 wfs irrespective of date/time those are ran)

#Print the list of workflows submitted last 5 days
$ oozie jobs -len 500 -filter startcreatedtime=-5d

(Oozie jobs -len 500 will list last 500 workflows, startcreatedtime filter will provide workflows created/submitted on last 5 days. )
(If the number of jobs in the last N days are more, change the len value accordingly)

#Print the list of workflows of a coordinator
$ oozie job -info $COORDINATORID 

#Print the list of killed workflows of a coordinator 
$ oozie job -info $COORDINATORID -filter status=KILLED
(Options: status=RUNNING, status=FAILED)

#Check the status of a workflow
$ oozie job -info $WFID

#Actions on a workflow
$ oozie jobs -run $WFID
$ oozie jobs -suspend $WFID
$ oozie jobs -resume $WFID
$ oozie jobs -kill $WFID

#Rerun a failed workflow. 
#This requires you to specify whether to run complete workflow from the beginning or only the failed steps.

$ oozie job -rerun $WFS -Doozie.wf.rerun.failnodes=true 
(This will rerun only the failed steps of the workflow)

$ oozie job -rerun $WFS -Doozie.wf.rerun.failnodes=false
(Rerun all the completed and failed ones)

#Rerun a bunch of failed workflows using 'for loop'.
for WFS in $(cat wflist.txt)
do
echo "Running the $WFS"
oozie job -rerun $WFS -Doozie.wf.rerun.failnodes=true
echo "$WFS completed successfully"
done
You can combine the shell utilities such as grep, awk, cut with this commands to experience the full power of cli depends upon your use case.

Appreciate your feedback and let me know if you found any other oozie cli commands useful.

2 thoughts on “Useful Oozie CLI commands

Leave a Reply

Your email address will not be published. Required fields are marked *