Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this should be simple?

Status
Not open for further replies.

cleansedbb

Technical User
Feb 11, 2002
95
US
I want to make a script that will be called by cron that will rotate a log file daily. this isnt a normal log file it's a html file so I want to archive it by date.
log.html should become ddmmyyyy.log

i've tried to define the format with printf but no luck.

command substitution: line1: syntax error near unexpected token 'printf('%02d%02d%04d',('
command substitution: line1: 'printf('%02d%02d%04d',('$Month$Day$Year))'

this is what I have

logfile=$(printf('%02d%02d%04d',($Month $Day $Year)))
 
Try :
#!/bin/sh
DATE=`date +%d/%m/%Y`
HTMLFILE=log.html
LOGFILE=$DATE.log
cp $HTMLFILE $LOGFILE ***************************************
Party on, dudes!
[cannon]
 
ok I couldnt get DATE='date+%d/%m/%Y'
to go. I changed it to DATE='date+%d%m%Y'

now for some reason instead of changing the name to the date I get

date+%m%d%Y.log

all I have in the code is this:

#!/bin/sh
echo "starting log rotation..."
Date='date+%m%d%Y'
HTMLFILE=test.html
LOGFILE=$DATE.log
cp $HTMLFILE $LOGFILE

echo "done"

exit 0
 
I just changed it and put a space between date +%d
and now I'm getting
cp copying multiple files but last argument "+%m%d%Y.log' is not a directory???
 
ok -- the ticks around the date command aren't standard quotes - this ' is a standard quote

use the backtick instead - this ` is a backtick

copy and paste the example Karver gave you and you'll see the difference Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
thank you, never even noticed that. works now :)
 
really common problem here, difficult to spot the difference between 'em.. Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
<-- Guess I shoulda pointed that out when I posted but beer and common sense don't go hand in hand :) ***************************************
Party on, dudes!
[cannon]
 
Well, *I* never drink and post at the same time....

WARNING - the above statement is a lie....

:) Mike
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Personally I'm amazed my post still makes sense .....(not that I had *that* much you understand)

:) ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top