AutoSys Workload Automation

 View Only

 Exit Codes

Corrie Kantowski's profile image
Corrie Kantowski posted Apr 26, 2022 11:37 AM

I am relatively new to AutoSys, and am looking for info on how exit codes work. We had a job run that failed, but was recorded in AutoSys as a success, with an exit code of zero. I am trying to troubleshoot and understand why.
1) does the operating system or the application where the job ran determine the exit code?
2) AutoSys documentation indicates that the log file for the job will display the exit code but I did not see the exit code in this job's log files.
3) the job that ran had one table load fail, but then numerous other table loads succeeded. Could this be why the exit code was a success?
4) Can the programmer of the job control what exit codes are sent back to AutoSys? Perhaps in his script?
5) Is it true that a script should explicitly mention a user defined exit code for AutoSys to mark it as failed?

Any other info you can provide is also greatly appreciated!

Chandrasekaran Venkataraman's profile image
Chandrasekaran Venkataraman
Autosys takes into account only the final exit code from the script/command to determine the status of the job. If the script has multiple commands and the last command in the script completes succesfully, then the job will be be success even when intermediate command/s fail/s. 
Same goes for command chaining. 
For example:
echo "hello"; /bin/false; /bin/true = job success
echo "hello"; /bin/true; /bin/false  = job fail

The programmer can certainly control the exit code within the script/code. 

There are ways to control job success/failure from Autosys too. Please look up max_success and success_codes JIL attributes
Michael Woods's profile image
Broadcom Employee Michael Woods
I agree with Chandra.  The exit code from the script or program is what determines success or failure.
So, if a script has multiple steps, a best practice is to check the return code of each step to determine if it should continue and exit with the appropriate 
exit code to ensure the job status represents what actually occurred during the execution.

Jose Lopez's profile image
Jose Lopez

I do not totally agree with what was said here. When any programs ends AutoSys will received a return code from the OS.

By standard if the return code is 0 then all was fine and the job is successful. But it the return code is not 0, AutoSys is basically the one who decides if the job was successful or not.

It does so by checking the parameters Chandra said or if not defined going into the default behaviour which is only RC=0 is success.

So the OS/programmer define the return code and Autosys decides if that means success or failure.