Clearing Old E-Mail from Queues
From CobaltFAQs
One of the common isses you may experience with your RAQ or Qube is that e-mail that is zero bytes in size or partial e-mails are not always deleted by Sendmail from the mail queues. The following script can be scheduled to run to delete zero byte and partial e-mails from the Sendmail mail queues automatically for you.
# delete zero byte files in sendmail queue
find /home/spool/mqueue/q1 \( -type f -a -size 0b \) -exec rm -f {} \;
find /home/spool/mqueue/q2 \( -type f -a -size 0b \) -exec rm -f {} \;
find /home/spool/mqueue/q3 \( -type f -a -size 0b \) -exec rm -f {} \;
find /home/spool/mqueue/q4 \( -type f -a -size 0b \) -exec rm -f {} \;
# delete files older than 7 days in sendmail queue
find /home/spool/mqueue/q1 \( -type f -a -mtime +7 \) -exec rm -f {} \;
find /home/spool/mqueue/q2 \( -type f -a -mtime +7 \) -exec rm -f {} \;
find /home/spool/mqueue/q3 \( -type f -a -mtime +7 \) -exec rm -f {} \;
find /home/spool/mqueue/q4 \( -type f -a -mtime +7 \) -exec rm -f {} \;
I recommend that you consider running this script daily or weekly in order to avoid an accumulation of files in your Sendmail queues.
--Chrisd 13:59, 3 February 2007 (PST)
I use this script, put into /etc/cron.hourly, to remove messages that are more than seven days old (remember to chmod +x the script so it will execute properly). Very similar to what Chrisd put above; I use the create time, rather than the last modified time.
#!/bin/sh
# check the outgoing mail spool and purge any files that are over
# seven days old
SPOOL=/home/spool/mqueue
for DIR in q1 q2 q3 q4
do
/usr/bin/find $SPOOL/$DIR -type f -ctime +7 -exec rm -f {} \;
done
--Bruce 08:11, 9 March 2007 (PST)
