Hello Miguel and list....

Here is a script I wrote some time ago for daily log table cleanup.
This should solve your problem.

/**************** logclean.php *********************/
<?php 
        $connection =
mysql_connect("localhost","your_db_login","your_db_password");
        mysql_select_db("mail" , $connection);

        $users = mysql_query("SELECT user FROM log group by
user",$connection);
        while ($user = mysql_fetch_row($users))
        {
                $result = mysql_query("SELECT * FROM log WHERE user =
'$user[0]' ORDER BY id",$connection);
                while ($row = mysql_fetch_row($result))
                {
                        for ($i=0; $i<mysql_num_fields($result); $i++)
                                $index = $row[0];
                }
                echo "Log cleanup for user ".$user[0]."\n";
                $result = mysql_query("delete from log where user='$user[0]'
and id != $index",$connection);
        }

        echo "Log cleanup finished" . date (" -  d.m.Y., H:i:s");
        echo "\n";
        $result = mysql_query("OPTIMIZE TABLE log",$connection);
        echo "Log table has been optimized \n";
        mysql_close ($connection);

?>
/************************* END*************************************/

Of course, don't forget to add this small script into your /etc/cron.daily
directory and make it executable by "chmod +x  filename".

#!/bin/bash
php /var/www/html/cyrus/logclean.php
 

Regards
Robert
****************************************************************************
****
>------------------------------
>
>Message: 2
>Date: Fri, 17 Nov 2006 16:56:27 +0100
>From: "Miguel ALBUQUERQUE" <[EMAIL PROTECTED]>
>Subject: Re: [Web-cyradm] webcyradm performance
>To: [email protected]
>Message-ID:
>       <[EMAIL PROTECTED]>
>Content-Type: text/plain; charset="us-ascii"
>
>how do i disable it ? have about 18 million rows on that table !
>
>
>
>Miguel Albuquerque
>Network Administrator



_______________________________________________
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