Remova o ponto na sua entrada crontab
da seguinte forma:
*/1 * * * * /home/usr/automation/check_rejected_files.sh > /home/usr/automation/cronout
esta é a entrada do cron
*/1 * * * * ./home/usr/automation/check_rejected_files.sh > /home/usr/automation/cronout
ele produz o arquivo mas nada mais acontece, eu adicionei um log de data no início do script para que eu possa ver se o script foi executado ou não, e nenhum logging acontece quando ele é acionado através do cron Aprecie sua ajuda 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
Remova o ponto na sua entrada crontab
da seguinte forma:
*/1 * * * * /home/usr/automation/check_rejected_files.sh > /home/usr/automation/cronout