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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
n0thingConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.