Hi Renat!

  This was exactly what I was looking for! logrotate cannot handle the
logs that emerge creates unfortunately so I had to use a custom script.
I had almost forgot the script that cleans up /tmp. So I created two
cron jobs, one in cron.weekly to bzip2 the newly created files with

find /var/log/portage/ -type f -name "*.log" -exec bzip2 -9q '{}' \;

(you really have to use "" when you are using wildcards in -name if
you don't want your find to have unpredictable results ;-)
and one in cron.monthly to delete the old month's log files with

find /var/log/portage/ -not -type d -mtime +30 -print0 |
        xargs --null --no-run-if-empty rm -f

Thank you a lot!

On Sun, 10 Aug 2003 02:26:41 +0200
Renat Golubchyk <[EMAIL PROTECTED]> wrote:

> On Sunday 10 August 2003 01:11, Theofilos Intzoglou wrote:
> >   It would be nice if the logs that emerge creates were compressed
> > with gzip of even better with bzip2. Another nice feature would be
> > to automatically erase the old ones. Are these features already
> > implemented? The reason I'm asking for these because recently I did
> > a du --max-depth=1 -k /var/log/ and I got:
> >
> > 4       /var/log/news
> > 4       /var/log/emerge
> > 316     /var/log/cups
> > 4       /var/log/mysql
> > 272936  /var/log/portage
> > 152     /var/log/samba
> > 281300  /var/log
> >
> > 270Megs of log files is kinda too much isn't it? ;-) There were logs
> > of emerges done in May in there! For now I'am erasing these manually
> > myself but I'd like to find a way to automate it. Thanks!
> 
> Well, you can make a script and put it, for example, under
> /etc/cron.weekly . Here is an example copied directly from the 'find'
> info page:
> 
> #---- cut here ----
>    Removing old files from `/tmp' is commonly done from `cron':
> 
>      find /tmp /var/tmp -not -type d -mtime +3 -print0 |
>        xargs --null --no-run-if-empty rm -f
> 
>      find /tmp /var/tmp -depth -mindepth 1 -type d -empty -exec rmdir
>      {} \;
> 
>    The second `find' command above uses `-depth' so it cleans out
>    empty
> directories depth-first, hoping that the parents become empty and can
> be removed too.  It uses `-mindepth' to avoid removing `/tmp' itself
> if it becomes totally empty.
> #---- cut here ----
> 
> You could change the lines to remove the files from /var/log/portage
> instead of /tmp and put them under cron.<something> .
> 
> For compression you can use something like this:
> find /var/log/portage/ -type f -name *.log -exec bzip2 -9q '{}' ';'
> 
> If you put it in file under cron.daily your portage log files will be 
> compressed once every day (if they are not compressed yet).
> 
> These too scripts would probably do what you want: compress the logs
> and remove the old ones.
> 
> 
> Cheers,
> Renat
> 
> 
> P.S. I don't have these scripts in my cron, just created them while
> writing this, but I just compressed my /var/log/portage with bzip and
> the size went down from 83MB to 3MB (with gzip 4MB). Those logs are
> mostly pretty small, there were only few big ones like 17MB for
> openoffice, 10MB for glibs, etc.
> 
> 
> --
> [EMAIL PROTECTED] mailing list
> 
> 


Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to