JohnO'Mullane

Unix Job not failing as I would expect even though I have "Exit 1" in my script

Discussion created by JohnO'Mullane on Dec 19, 2017
Latest reply on Jan 2, 2018 by JohnO'Mullane
Hi,
 I have a Unix shell script which has completed successfully but I expected it to fail.

I have an Exit 1 in my code 


echo "Checking DNFS....."
   count=`sqlplus -s '/ as sysdba'<<EOF
   set pagesize 0 feedback off verify off heading off echo off
   select count(*)  from v\$DNFS_stats where nfs_read >0 or nfs_write >0;
   EOF`

   if [[ "${count}" = '0' ]]; then
      echo "DB NOT running on DNFS"
      exit 1;
   else
      echo "DB running on DNFS"
   fi
   
   #jdkv=`cat /tmp/$1_jdkver.log`
   jdkcnt=`cat /tmp/$1_jdkver.log|wc -l`
   jdkver=`expr $jdkcnt`
   if [ $jdkver -eq 1 ]; then
      echo "Java working query passed"
   else
      echo "Java working query failed, Please check JAVA"
      exit 1;
   fi

When I run the Job, it's getting to this place in the code and exiting, but not failing.


awos96ulnqn5.png

I have done a little test myself with a simple unix Job I created with only this code

7mm4qhcic2ia.png

When I called from Automic, it behaved as I expected, job failed.

mm666odreb7o.png


Has anyone seen this behavior before?

John.

Outcomes