I've been using a script I wrote based on this thread for several months to remove certain mass emails from the queue. I've just discovered a problem with this method that others may like to know about.
It started when I noticed that it was taking a very long time to grep the few hundred messages in the queue - well over 10 minutes, probably more. So I decided to take a little look inside the directories inside /var/spool/exim/input and instantly noticed there were many, many more files than there should be. After some poking around, I soon discovered the problem: Exim stores the message headers in separate files to the message bodies, and this method of removing messages only removes the headers! I still had the message bodies from month's worth of deleted mail sitting there. I counted the files and there were well over 150,000 of them, that's over 600MB of data. No wonder grep was taking so damn long
I did the following to clean up the mess, without removing the few legitimate messages in the mail queue:
Code:
cd /var/spool/exim/input/
for f in */*-D; do if [ ! -f `echo $f | tr -- -D -H` ]; then rm -f $f; fi; done
This command is still running and has so far removed about 100MB worth of files. It's not exactly fast, but it's working
