LOG_FILE variable

I have a script that emails me a backup log upon completion.  The problem I am running into is if the log file is created tonight with a date of 1/28 and the backup ends tomorrow with a date of 1/29 and I issue the command to send the log file after the backup completes, it does not recognize the log file since the date stamp it has is from the night before.  My scripts are listed below:

1. call_prod_bu.sh

LOG_FILE=`date +%y%m%d`
export LOG_FILE
/usr/bin/su - oracle -c /home/scripts/rman/prod_bu.sh > /home/scripts/logs/$LOG_
FILE.prod_bu.log 2>&1

2. prod_bu.sh
set -v
. .profile
echo $PATH

cd /home/scripts/rman

rman rcvcat rman/password@rcv << EOF
connect target
run {execute script prod_bu;}


3.  prod_sendlog.sh

. .profile
LOG_FILE=`date +%y%m%d`
export LOG_FILE
/usr/bin/mailx -s "prod cold backup" slow@hmsnet.com < /home/scripts/logs/$LOG_FILE.prod_bu.log

I know the scripts were broken up into three for some reason but I am not sure why.  They were created by someone else.

Any ideas?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

tfewsterConnect With a Mentor Commented:
How does prod_sendlog.sh get kicked off? If it is from the controlling script (call_prod_bu.sh), just remove the line that sets the LOG_FILE variable from prod_sendlog.sh so it inherits it from its parent process.

Alternatively, in call_prod_bu.sh, save the date in a file (echo $LOG_FILE` > /tmp/bu_date), and in prod_sendlog.sh read it from the file (LOG_FILE=`cat /tmp/bu_date`). This will allow prod_sendlog.sh to be run from the command line without the problem of LOG_FILE being uninitialised.

suzanlowAuthor Commented:
Thanks.  I tried your first suggestion and it works great!
All Courses

From novice to tech pro — start learning today.