Date Variable in Cron Job

I'm using the following command in CRON to run a backup job and pipe the output to a log file.  

/usr/bin/su - oracle -c /home/scripts/rman/fins_hot_bu.sh > /home/scripts/logs/fins_hot_bu.log 2>&1

Currently the name of the log file is "fins_hot_bu.log", but I would somehow like to incorporate the date into the name of the file so it doesn't get overwritten every night.  Is there a variable I can put into the name of the log to indicate the date?  I would like something like (but doesn't have to be exactly this format)  - fins_hot_bu_111899.log, or something comparable.

Thanks,

Lisa Phillips
lphillips120898Asked:
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.

n0thingCommented:
You could do a wrapper around that, here is the
scripts:

#!/bin/sh
DATE=`date +%m%d%y`
/usr/bin/su - oracle -c /a/b/c > /a/b/c/fins$DATE.log >2&1

And just place this script in the cron.
0

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
lphillips120898Author Commented:
I put the following in a script:

# more local_nike.sh
date
DATE='date +%m%d%y'
vdump -0 -N -U -v -f /dev/rmt0h / > /home/scripts/logs/local_nike_$DATE.log
vdump -0 -N -U -v -f /dev/rmt0h /usr > /home/scripts/logs/local_nike2_$DATE.log
vdump -0 -v -f /dev/rmt0h  /u01 > /home/scripts/logs/local_nike3_$DATE.log
date
exit

THIS WAS THE LOGFILE OUTPUT - WITH 0 BYTES
local_nike_date +%m%d%y.log
local_nike2_date +%m%d%y.log
local_nike3_date +%m%d%y.log


I ALSO PUT THE FOLLOWING IN CRON AND IT DIDN'T EVEN PRODUCE A LOG:

34 14 * * * DATE='date +%m%d%y' /home/scripts/networker/local_medusa.sh > /home/scripts/logs/local_medusa_$DATE.log


What am I doing wrong?
0
n0thingCommented:
I'd use the backquote ... ` ... not the straight regular
front ' quote. So I think you used the wrong quote.
It's not very clear in my answer .. but if you copy
my script .. you'll see.

Regards,
Minh Lai
0
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.