Job fails with Exit code 1 while the Exit code 0 is reported in the agent log file.
The job definition:
insert_job: jobname job_type: CMD
box_name: boxname
command: ls /testfolder/folder2/us/file.dat
machine: machine-name
permission: gx,ge,wx,we,mx,me
date_conditions: 0
description: "Check for file.dat file"
std_out_file: "> /tmp/$AUTO_JOB_NAME.out"
std_err_file: "> /tmp/$AUTO_JOB_NAME.err"
alarm_if_fail: 1
success_codes: 2
Release : 11.3.6
Component : CA Workload Automation AE (AutoSys)
The "Exit Code 1" is simply a "Generic Exit Code" which means the job failed and this can be for any reason.
In the joblog however, we can find the script completed with an "Exit code 0" which means "No errors" on the execution of the script on the Agent:
.....
Sat Aug 1 16:44:20 2020 CAWA_I_20018 Job failed. Exit code 0, Status:
This means that the job ran without any problems on the Agent and returned the “Exit code 0” which means “No errors” as a general rule.
However, in your job definition you have set “success_codes: 2”:
insert_job: test-jobname
job_type: CMD
command: ls /testfolder/folder2/test.dat
.....
success_codes: 2 < =====
This means that for the job to be considered as “success” you need the following command to return the “Exit code 2”:
command: ls /testfolder/folder2/file.dat < =====
You will need to investigate the reason why the command:
ls /appl/sap/us/file.dat
is expected to return an exit code 2 and why it returns 0 instead of 2 since you have begun to encountered the issue.
This is Not an AuoSys issue and needs to be investigated at your scripts level.
However, you can use the information reported in standard files if any for more information:
std_out_file: "> /tmp/$AUTO_JOB_NAME.out"
std_err_file: "> /tmp/$AUTO_JOB_NAME.err"
The exit code is zero in agent log because the script was ran successfully by the agent without any errors.
The reason why there is an error code 1 reported in the event_demon log is that you have set the following attribute in your job definition:
success_codes: 2 < =====
This means that AutoSys will consider the job as Success “Only” when the Scripts Return code is 2 per your job definition.
Otherwise the job will be considered as failed and the generic Exit Code 1 will be sent which means failure per your job definition.
This is Not an AutoSys issue. AutoSys is behaving exactly as expected.
You will need to investigate why your script is supposed to return the Exit Code 2 and why it does not do that.