Combine daily access logs to single monthly log cron job
Posted: Sun Dec 16, 2007 7:57 pm
I just added this to a sever I use though am waiting for the cron job to execute.
My question though is how can I amend the file name to include the numerical month and year?
So I want the monthly access log files to look like...
mydomain.com-2007-01.gz
mydomain.com-2007-02.gz
mydomain.com-2007-03.gz
mydomain.com-2007-04.gz
Here is the basic code. I don't know if this will generate a log file that grows so long as you leave the original daily access logs though? If I get this working I'm so going to post a whole page on my site dedicated to conquering this issue alone!
My question though is how can I amend the file name to include the numerical month and year?
So I want the monthly access log files to look like...
mydomain.com-2007-01.gz
mydomain.com-2007-02.gz
mydomain.com-2007-03.gz
mydomain.com-2007-04.gz
Here is the basic code. I don't know if this will generate a log file that grows so long as you leave the original daily access logs though? If I get this working I'm so going to post a whole page on my site dedicated to conquering this issue alone!
Code: Select all
zcat access.log.*.gz > monthlylog.txt
gzip monthlylog.txt