PDA

View Full Version : compressing web.log files


todvard
12th July 2006, 14:00
Hi all,

i have found that the old log files in webxx/log folders are too big, thats why i have created this bash script to compress those files.
The script is short (and ugly too, i know :), but it's working ):


#!/bin/sh

for i in `find /var/www/ -type f -mtime +2 -name web.log | grep -v "/\`date +%m\`/"` ; do gzip $i; done


Run it from cron every day, after ISPConfig's log.php script (which is running 0.30 AM every day in the default installation)

fobicodam
12th July 2006, 15:43
mmm are this logs files usefull for something? if after the zip every is ok, i prefer to delete them...

TheRudy
12th July 2006, 18:10
mmm are this logs files usefull for something? if after the zip every is ok, i prefer to delete them...
Site gets hacked while you are away for 2 days, you can check logs if you still have them.. :) So yeah, they can be usefull

fobicodam
12th July 2006, 18:37
mmm Site has been hacked, im away two days... should i check a 2 Gb text file to see whats modified or should i restore a backup?... my choice is a backup..

todvard
12th July 2006, 19:07
If you want to avoid to be hacked for second time, then yes, you should check those 2GB text files :) anyway, it is up to you.

TheRudy
12th July 2006, 21:06
What todvard said.. but it is indeed decision made by you, if you use backup thinking that bug will be resolved by itself then fine by me.. :D

falko
13th July 2006, 14:26
mmm are this logs files usefull for something? if after the zip every is ok, i prefer to delete them...
There's also a legal reason: in some countries you must keep log files for at least a few months if you provide hosting services.

fobicodam
13th July 2006, 14:51
Im lucky its not here.. but anyway, my big problem is the 2Gb limit for files. Can i somehos change the script to not append everyday log file to the bi main file? i mean, save daily log in separate files?

till
14th July 2006, 10:07
If you split the log in daily files, you might get problems with the webalizer stats generation.

You can try this by modifying the script /root/ispconfig/scripts/shell/logs.php