james wrote:

Hello.

I set up the webcyradm  and it work great!

But I found it runs for two month , the log table more than 550000 records ,

How to delete some , or just use the mysql to drop the old records.

Regards

bua, don't post in HTML please...

i have asked for this a time ago, but i don't find the Reply nor my Mail in my Imap directory, seems that i have deleted this mails, and as the mailinglist archives do not work, i will try to help you. When i had this problem, someone of the guys on this list sent me the attached php script, what i have put in /usr/local/scripts/cyradm-logclean.php, then i create a new file in /etc/cron.weekly:

#!/bin/sh
php /usr/local/scripts/cyradm-logclean.php


----------- cyradm-logclean.php ---------------
<?php
       $debug = false;
       $connection = mysql_connect("localhost","mail","7gyqftqe");
       mysql_select_db("mail" , $connection);

$users = mysql_query("SELECT user FROM log GROUP BY user",$connection);
       while ($user = mysql_fetch_row($users))
       {
if ($debug == true) { echo "Processing logs for user ". $user[0]."\n"; } $result = mysql_query("SELECT * FROM log WHERE user = '$user[0]' ORDER BY id",$connecti
on);
               while ($row = mysql_fetch_row($result))
               {
                       for ($i=0; $i<mysql_num_fields($result); $i++)
                               $index = $row[0];
               }

$result = mysql_query("DELETE FROM log WHERE user='$user[0]' and id != $index",$connect
ion);
       }
if ($debug == true) { echo "Log clean completed " . date (" - d.m.Y., H:i:s") . "\n"; }
       $result = mysql_query("OPTIMIZE TABLE log",$connection);
       if ($debug == true) { echo "Log table has been optimized. \n"; }
       mysql_close ($connection);
?>
------------ <eof> ----------------


Hope this helps...


Christian
_______________________________________________
This mailing list is hosted and supported
by bit-heads GmbH | http://www.bit-heads.ch

_______________________________________________
Web-cyradm mailing list
[email protected]
http://www.web-cyradm.org/mailman/listinfo/web-cyradm

Reply via email to