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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suzanlowAuthor Commented:
Thanks.  I tried your first suggestion and it works great!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.