How do I add the current date to a filename?
I am trying to set up a cron job to automatically zip my logs at the end of each day. I had someone set up a cron job for me to tar the logs but it isn't compressing the logs well enough.
What I want to be able to do is to run a command that takes a specific file and zip it into another file that includes the current date. For example: Take the file log.daily and zip it into a file daily.log.03.18.05.zip (assuming that todays date is March 18, 2005)
I have tried accomplishing this a number of ways. Here is one method I have tried:
zip /usr/local/apache/logs/daily.log.'date +\%m.\%d.\%y'.zip /usr/local/apache/logs/*.daily
The end result of this command is a file named daily.log.date +\%m.\%d.\%y.zip
The desired result again would be a file named daily.log.03.18.05.zip. I know this is possible, but I just don't know the correct syntax.
I would appreciate any help that you can give me.
Thanks in advance,