Trim the maillog mysql db in mailscanner

From time to time the maillog in mysql grows to big and eats up all the space on my mail filter, the end result it stops processing mail 🙁

The problem becomes worse if you have no space left to try and repair the MySQL file, so make sure you check the free space regularly!!!!!!

[root@myserver mailscanner]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18414 to server version: 4.1.20

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use mailscanner
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> delete from maillog where timestamp “LT” date_sub(curdate(), interval 90 day);
Query OK, 101491 rows affected (1 min 46.40 sec)
optimize table maillog;

+———————+———-+———-+———-+
| Table               | Op       | Msg_type | Msg_text |
+———————+———-+———-+———-+
| mailscanner.maillog | optimize | status   | OK       |
+———————+———-+———-+———-+
1 row in set (25.22 sec)
mysql> exit
Bye

some times I have to use this line below substituting the one above.

delete from maillog where timestamp < date_sub(curdate(), interval 14 day);


Was this post helpful?

Total Page Visits: 699 - Today Page Visits: 2