1

I have a script which is in Autosys Job : JOB_ABC_S1

command : /ABC/script.sh

Scrpt.sh code

grep -w "ABC" /d/file1.txt

status=$?

if [ $status -eq 0 ]
then 
    echo "Passed"
else
    echo "Failed"
    exit 1
fi 

My issue is even if the script failed or pass , the AutoSys job is marked as SU SUCCESS

I don't want it to mark it as success , if script fail's .. it should mark AutoSys as FA and if script pass then mark job to SU SUCCESS

What should i change in the script to make it happen ?

Job :

insert_job : JOB_ABC_S1
machine : XXXXXXXXXXX
owner : XXXXXXXX
box_name : BOX_ABC_S1
application : XXXX
permission : XXXXXXXXXXX
max_run_alarm : 60
alarm_if_fails : y
send_notification : n
std_out_file :  XXXXX
std_err_file :  XXXXX
command :  sh /ABC/script.sh
codeholic24
  • 955
  • 4
  • 22

1 Answers1

2

At first look all seems to be fine.

However, i would suggest a script modification which you can try out. By default Autosys fails the jobs if the exit code is non-zero unless specified.

JOB JIL seems to be fine.

Please update your script as below and check for 2 things:

  1. Executed job EXIT-CODE: either it should be 1 or 2. We are trying to fail the job in both the cases.
  2. Str log files

Script:

#!/bin/sh
srch_count=$(grep -cw ABC /d/file1.txt)
if [ $srch_count -eq 0 ]; then
    echo "Passed"
    #exit 0 
    exit 2
else
    echo "Failed"
    exit 1
fi

This way we can confirm if the exit code is correctly being captured by Autosys.

Piyush
  • 818
  • 8
  • 17
  • apart from this do you have any … other approach to FA job – codeholic24 Jan 15 '21 at 10:57
  • not sure what is causing it ! Try: User-defined Exit Code in JIL with attributes success_codes or fail_codes Change the script to run with bash -x /filename try in any other host apart from linux or scripting language perl / python – Piyush Jan 15 '21 at 11:07
  • create a cmd job with command as exit 101 see what happens – Piyush Jan 15 '21 at 11:07