Sat, 23 Dec 2006

postfix: delete all mail in the queue

    Easy way: as root, type -- postsuper -d ALL
                               postfix reload
    
Note:  this is a very powerful command as it deletes 
ALL mail in the queue.

## get the mail-ID and other junk in the first column
mailq | nawk '{print $1}' > tmp-mailq

## remove the junk line starting with (tra
## repeat as necessary if other junk lines are present
## repeat once also for blank lines
## manually edit to remove any other extraneous lines
cat tmp-mailq  | sed '/^(tra/d' > tmp-mailq-2
cat tmp-mailq2 | sed '/^$/d'    > tmp-mailq-3

## write a short script to loop through postsuper -d
## with the mail-ID's

   #!/bin/sh
   exec < tmp-mailq-3
   while read line
   do
      postsuper -d $line
   done

## run the script; mailq should be clean

Posted at: 13:01 | category: /mail | Comments ()