Forum Moderators: coopster & phranque

Message Too Old, No Replies

Daily Archiving of Log files

         

msgraph

2:25 pm on May 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the best way to archive raw log files each night before they get overwritten for the next day. I've had other methods for getting it done in the past but I want to do it myself this time.

I want to have them archived in either .gz or .bz2 format with a date file naming scheme.

What is the best way to set this up?

william_dw

1:21 am on May 2, 2002 (gmt 0)

10+ Year Member



If you're using a linux system then logrotate is the best option that i can think of, files can be zipped based upon date (daily,weekly), size (>50mb), etc.

Just do a man logrotate on your linux box, or look it up at the LDP.

HTH,
Dw

sugarkane

1:27 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It can be done with a shell script run as a cron.

#!/bin/bash
DATE=`date +%d%m%y`
cp access_log $DATE
gzip $DATE

...will copy access_log into a file named as the date (ddmmyy in the above example) and then put it into .gz format. You can then schedule it to run every day using cron, as explained in Air's cron tutorial [webmasterworld.com]

msgraph

1:44 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great thanks! I'll give it a try.