Hello Christian,
Thanks for this nice script.
I've made cronjob
# crontab -e
30 21 * * 6 /data/cronjobs/cyradm-logclean.php
And this is the script adjusted to mysql:
----------- cyradm-logclean.php ---------------
#!/usr/bin/php
<?php
$debug = false;
$connection = mysql_connect("localhost","mail","secret");
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",$connection);
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",$connection);
}
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> ----------------
Regards,
Leon Kolchinsky
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christian Anton
Sent: Thursday, September 22, 2005 11:00 AM
To: [email protected]
Subject: Re: [Web-cyradm] delete the log at database
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
_______________________________________________
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