• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Can't get BASH script to work, problem with variables

My web host only keeps the raw apache log for 1 day.  I'm trying to copy that file over and rename it with the date.  I'm running a BASH script from a cron job.  Here is the script that doesn't work

DATEVAR= date --date=yesterday +%Y-%m-%d
cp /...logs/access_log.1 /.../logs_aggregate/
mv /.../logs_aggregate/access_log.1 /.../$DATEVAR

It copies the log file, but doesn't like the $DATEVAR, anything static works fine.  If I type 'echo $DATEVAR' it prints yesterdays date in the format I want it, '2006-04-19'

So in a nutshell, I want to copy the log file to a new location and rename it with the revious days date.

I just started with bash scripting, so I know I am overlooking something silly, but I've been working on this off and on for over a week.

1 Solution
DATEVAR=`date --date=yesterday +%Y-%m-%d`
AmaddeusAuthor Commented:
I see, the funny quote and no space after the =


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now