0
drwxr-xr-x  2 smmsp smmsp  4.0K May  6 23:31 mqueue
drwxrws---  2 smmsp smmsp  29M May  8 10:40 mqueue-client

As you can see mqueue-client is filled with 29 megabytes of unsent mail. This seems to be likely from an internal function sending mail to localhost which is failing.

I've tried numerous attempts to clear the queue but none have succeeded. The result is a process using up significant CPU resources:

16287 smmsp     20   0 50212  44m 2416 R   85  4.4 965:35.45 sendmail-msp

I've tried killing the process, stopping the sendmail service, deleting the contents of the mqueue-client and even switching to the smmsp user. But none have worked. rm hangs when trying to remove the mail.

How can I go about emptying this queue?

Once I've done this I'll move everything over to Postfix.

4
  • Logs, my friend, logs. Have you read them at all? Boldly enter /var/log lair and see what it holds. May 8 '14 at 12:35
  • thanks @janne you helped me solve the problem, see my answer for more info
    – Brodie
    May 8 '14 at 19:30
  • Great! Have a nice weekend. :) May 9 '14 at 9:41
  • To remove multiple files you can use find command like find /path/to/files/ -type f -name '*.txt' -exec rm {} \; Sep 18 '18 at 8:25
0

As suggested by Janne in the comments, I looked over my syslog and found many mail failing to send errors which was causing them to be deferred thus pile up in the mqueue-client folder.

After doing some digging it turns out crontab is set to mail root on completion/notices/warnings/errors. By issuing crontab -e and adding MAILTO="" to the top of the config, no more mail is sent out, problem fixed!

Now I'm clearing out the 1.5 million or so bad emails from mqueue-client using this Bash script:

#!/usr/bin/env bash

cd mqueue-client

deleted=0

for i in `ls`
do
        rm -f $i
        percentage=$(bc <<< "scale=2; ($deleted / 1035435) * 100")
        ((deleted++))

        echo "Deleted $i. Files deleted $deleted. $percentage% complete."
done

Run from /var/spool using ./filename

Update

Unfortunately after running this script all night the mail queue wasn't being significantly reduced. This was because I hadn't disabled the minute running CRON that was set to clear the queue but was resulting in the backlog growing. Hopefully now this is disabled everything should clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.