Thursday, March 7, 2013

Pentaho Kettle (PDI): Get Pan and Kitchen Exit Code

Various monitoring applications require the exit code/status of a process as an input.

A simple example (

echo "Hi"
exit $?

Let’s run it:
$ ./
Let’s check the exit status (of the last command) which can be accessed via $?:
$ echo $?

Let’s take a look at how we can get the exit status from Pan and Kitchen:

For demonstration purposes we create a very simple dummy transformation which just outputs some data to the log:
Now create a shell file:
/opt/pentaho/pdi/pdi-ce-4.4.0-stable/ -file='/home/dsteiner/Dropbox/pentaho/Examples/PDI/exit_code/tr_dummy.ktr' -Level=Basic > /home/dsteiner/Dropbox/pentaho/Examples/PDI/exit_code/err.log
echo $?

Note the echo $? in the last line which will return the exit status. This is for demonstration purposes here only. Normally you would use exit $? instead.

On Windows use instead:

Now lets run the shell script:
The exit status tells us that the transformation was executed successfully.

Next we will introduce an error into the transformation. I just add a formula step with a wrong formula:
We run the shell script again and this time we get a return code other than 0:
Any return code other than 0 means it is an error.

Please find below an overview of all the return codes (src1, src2):

Error Code
The job ran without a problem
Errors occurred during processing
An unexpected error occurred during loading / running of the job / transformation, an error in the XML format, reading the file, problems with the repository connection, ...
unable to connect to a database, open a file or other initialization error.
The job / transformation couldn't be loaded from XML or the Repository
Error loading job entries or steps or plugins (error in loading one of the plugins mostly).one of the plugins in the plugins/ folder is not written correctly or is incompatible. You should never see this anymore though. If you do it's going to be an installation problem with Kettle.
Command line usage printing


  1. Hi, this does not work for me. Even if the ktr fails - like if DB password is wrong, have an Abort step or if the target table name is given wrong, always returns 0. Any help is greatly appreciated.

    1. I think you need to update your Kitchen.bat or Pan.bat files. Add echo %ERRORLEVEL% as last line of those files. Then it would return proper error codes. Atleast it worked for me :)

    2. EXIT /B %ERRORLEVEL% at the end of kitchen or pan batch file