From 260359acbb8c3f968aea303d887e2c472ce1a297 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 16 Oct 2012 14:52:05 +0200 Subject: [PATCH] Add a script to remove old entries from the database, default keeps 2 years of logs --- root/etc/cron.daily/qpsmtpd-db-cleanup | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 root/etc/cron.daily/qpsmtpd-db-cleanup diff --git a/root/etc/cron.daily/qpsmtpd-db-cleanup b/root/etc/cron.daily/qpsmtpd-db-cleanup new file mode 100644 index 0000000..898e3d2 --- /dev/null +++ b/root/etc/cron.daily/qpsmtpd-db-cleanup @@ -0,0 +1,15 @@ +#!/bin/bash + +LOG=$(/sbin/e-smith/db configuration getprop qpsmtpd Log2Sql || echo 'disabled') + +if [ "$LOG" != "enabled" ]; then + exit 0 +fi + +RETENTION=$(/sbin/e-smith/db configuration getprop qpsmtpd Log2SqlRetention || echo 730) +DB=$(/sbin/e-smith/db configuration getprop qpsmtpd DbName || echo smtp_log) + +echo "delete from rcpts where mail_id IN (select mail_id from messages where date_day