¿Mi script bash no funciona cuando lo activa crontab, pero funciona cuando lo activo manualmente?

¿Mi script bash no funciona cuando lo activa crontab, pero funciona cuando lo activo manualmente?

esta es la entrada cron

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

produce el archivo pero no sucede nada más, agregué un registro de fecha al comienzo del script para poder ver si el script se ejecutó o no, y no se produce ningún registro cuando se activa a través de cron. Agradezco su ayuda, gracias

Guion

#! /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

Respuesta1

Elimina el punto en tu crontabentrada de esta manera:

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

información relacionada