Return code of UNIX script not transmitted to the Job that launched it

Document ID : KB000115985
Last Modified Date : 01/10/2018
Show Technical Document Details
Introduction:
"We have an issue during a Unix JOBS execution. The script executed by the job is returning an error code 1, but the Job is ending OK.
Is it normal ? If yes, how can I pass the error code of the script to the Job status ?"

 
Background:
Here is how the Unix job has been configured:

User-added image

The jbu_test.sh is a simple script which only performs an "exit 1".
When we run it, the job is returning a ENDED_OK status:

User-added image

And if we check the job report, we can see that the script is returning an error 1:

User-added image
Environment:
Automation Engine 12.0 and above.
Instructions:
It is normal that the job is not retrieving the script status. To perform this, you should change the "echo $?" to a "exit $?":

User-added image

When running, the job is now returning an ENDED_NOT_OK status, according the status of the script launched in it:

User-added image