0

this is the cron entry

*/1 * * * * ./home/usr/automation/check_rejected_files.sh > /home/usr/automation/cronout

it produce the file but nothing else happen, i added a date log in the beginning of the script so i can see if the script ran or not , and no logging happens when it triggers through cron Appreciate your help thx

Script

#! /bin/bash
#
#
now=$(date)
echo $now >> $ASfile

*emphasized text*
##########o 
#Variables #
############

ASfile='AlertsSent.txt'
Rlines=$(cat $ASfile)
Alerted="false"
Recipient="mymail"

USERNAME='usr'
PASSWORD='pass'
SERVICE_NAME='service'
#####################
#Query List from DB #
#####################

RejectionQueryOutput=$(sqlplus -s $USERNAME/$PASSWORD@$SERVICE_NAME <<END
        set showmode off;
        set trimout on;
        set feedback off;
        set  verify off;
        set  heading off;
        set  echo off;
        set pagesize 0;
        set termout off;
    select mmfile.name from file_status INNER JOIN mmfile ON file_status.file_id=mmfile.id where file_status.state='BANK_REJECTED' and file_status.type='CURRENT' and file_status.datetime > sysdate - 6 and (mmfile.type='PAIN008_EPC' or mmfile.type='PAIN008_CGI' or mmfile.type='PAIN008_CBI' or mmfile.type='PAIN008_DIAS' or mmfile.type='PAIN001_EPC' or mmfile.type='PAIN001_CGI');
    exit;
END
)

ExportedQueryOutput=$(sqlplus -s $USERNAME/$PASSWORD@$SERVICE_NAME <<END
        set showmode off;
        set trimout on;
        set feedback off;
        set  verify off;
        set  heading off;
        set  echo off;
        set pagesize 0;
        set termout off;
     select mmfile.name from file_status INNER JOIN mmfile ON file_status.file_id=mmfile.id where file_status.state='EXPORTED' and file_status.type='CURRENT' and file_status.datetime < sysdate - 2/24 and file_status.datetime > sysdate - 6 and (mmfile.type='PAIN008_EPC' or mmfile.type='PAIN008_CGI' or mmfile.type='PAIN008_CBI' or mmfile.type='PAIN008_DIAS' or mmfile.type='PAIN001_EPC' or mmfile.type='PAIN001_CGI');
    exit;
END
)
tifs=$IFS
IFS=' '
RejectedArray=( $(for i in $RejectionQueryOutput ; do echo $i ; done) )
ExportedArray=( $(for i in $ExportedQueryOutput ; do echo $i ; done) )
IFS=$tifs
#######
#Main #
#######
#Rejected 
for i in ${RejectedArray[@]}
do
        for rline in $Rlines; do
                if  [ "$i" == "$rline" ]
                then
                        Alerted="true"
                        break
                fi
        done

        if [ "$Alerted" == "false" ]
        then
                echo $i "Rejected"  >> $ASfile
                echo "file $i have been rejected by bank please take action" | mail -s "[SEPA] raising alarm: $i have been rejected" $Recipient
        fi
Alerted="false"
done
ASfile='AlertsSent.txt'
Elines=$(cat $ASfile)
#Stuck Exporting
for x in ${ExportedArray[@]}
do
        for eline in $Elines; do
                if  [ "$x" == "$eline" ]
                then
                        Alerted="true"
                        break
                fi
        done

        if [ "$Alerted" == "false" ]
        then
                echo $x "Long-Exporting"  >> $ASfile
                echo "file $x have been in Exported state for more than 2 hours" | mail -s "[SEPA] raising alarm: $x have been in Exporting state for more than 2 hours" $Recipient
        fi
Alerted="false"
done
  • Can you explain yr 7th script line ? – Cbhihe May 15 '16 at 16:04
2

Remove the dot in your crontab entry like this:

*/1 * * * * /home/usr/automation/check_rejected_files.sh > /home/usr/automation/cronout
  • He/she/it might as well also replace the */1 with *. – Cbhihe May 15 '16 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.