[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Log ownership



Glenn Cameron wrote on 14.03.2002:

> The logs for sites are a big problem for pushing folks over quota, trouble
> is I can significantly increase their quota but that only means the logs
> take up a large percentage again - site had 300Mb quota, I increase to 500Mb
> but now logs are using 300mb!! Space isn't really a problem so what I was
> thinking was to make all the logs owned by root group as well as user root
> so they don't count against group quota. Anybody done something along those
> lines? Suggestions on simple way to proceed?


The following is a cgi-script which rebuilds the log-configuration for
logrotate so that you have small logfiles for each of your site:

-- snip --
#!/usr/bin/perl
# allsites-logrotate.cgi V 1.1

system("rm -f /etc/logrotate.d/site*");
system("rm -f /etc/logrotate.onboot/site*");
system("rm -f /etc/logrotate.d/home");
system("rm -f /etc/logrotate.onboot/home");

open(LOGROTATEDATEI, ">/etc/logrotate.d/allesites") || die "Konnte Datei /etc/logrotate.d/allesites nicht oeffnen\n";

    print LOGROTATEDATEI "/home/sites/home/logs/mail.log {\n   missingok\n   compress\n   size 100k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/home/logs/ftp.log {\n   missingok\n   compress\n   size 100k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/home/logs/web.log {\n   missingok\n   compress\n   size 1M\n}\n\n";

  for ($i=1; $i<=200; $i++) {
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/mail.log {\n   missingok\n   compress\n   size 100k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/ftp.log {\n   missingok\n   compress\n   size 100k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/web.log {\n   missingok\n   compress\n   size 1M\n}\n\n";
  }

close(LOGROTATEDATEI);
-- snap --



The following is a shell-script, which removes analog cache- and
stat-files from the sites log-directory:

-- snip --
#!/bin/sh
# remove-cache-stats.sh

rm /home/sites/site*/logs/web.cache*
rm /home/sites/site*/logs/web.stats

rm /home/sites/site*/logs/ftp.cache*
rm /home/sites/site*/logs/ftp.stats

rm /home/sites/site*/logs/mail.cache*
rm /home/sites/site*/logs/mail.stats
-- snap --



The following very easy ;-) script chowns all files in a sites
log-directory to the root-user:

-- snip --
#!/bin/sh
# chown-logs-to-root.sh

chown root.root /home/sites/site*/logs/*
-- snap --


place these scripts as root-user in your folders /etc/cron.daily, /etc/cron.weekly
or /etc/cron.monthly and make them executeable using "chmod 700 nameofscript"

I use all three scripts scripts above on several RaQs without any problems.

allsites-logrotate.cgi and chown-logs-to-root.sh in /etc/cron.daily
remove-cache-stats.sh in /etc/cron.weekly

HTH,
Daniel

-- 
free backup-solution for your RaQ:
http://www.neuhaus-internet.de/cobalt/raqbackup/