Is it a correct way to clear the exim mail queue?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I use the following command to delete the exim mail queues



exiqgrep -i | xargs exim -Mrm


or



# following commands seems to work faster compared to the above.
exim -bpru | awk 'print $3' | xargs exim -Mrm


But the above commands do not work when the mail queue size is more than 100,000. It get stuck. So, I am using the following script which works fine regardless of the number of mails in the queue.



My question is, will it delete correctly ?



/etc/init.d/exim stop;
sleep 10;
killall -9 exim eximd
sleep 5;

#clean out the mail queue
find /var/spool/exim -mindepth 2 -type f -exec rm -rfv ;

#clean out the mail db files
find /var/spool/exim/db -type f -exec rm -rvf ;

/etc/init.d/exim restart









share|improve this question

























    up vote
    3
    down vote

    favorite












    I use the following command to delete the exim mail queues



    exiqgrep -i | xargs exim -Mrm


    or



    # following commands seems to work faster compared to the above.
    exim -bpru | awk 'print $3' | xargs exim -Mrm


    But the above commands do not work when the mail queue size is more than 100,000. It get stuck. So, I am using the following script which works fine regardless of the number of mails in the queue.



    My question is, will it delete correctly ?



    /etc/init.d/exim stop;
    sleep 10;
    killall -9 exim eximd
    sleep 5;

    #clean out the mail queue
    find /var/spool/exim -mindepth 2 -type f -exec rm -rfv ;

    #clean out the mail db files
    find /var/spool/exim/db -type f -exec rm -rvf ;

    /etc/init.d/exim restart









    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I use the following command to delete the exim mail queues



      exiqgrep -i | xargs exim -Mrm


      or



      # following commands seems to work faster compared to the above.
      exim -bpru | awk 'print $3' | xargs exim -Mrm


      But the above commands do not work when the mail queue size is more than 100,000. It get stuck. So, I am using the following script which works fine regardless of the number of mails in the queue.



      My question is, will it delete correctly ?



      /etc/init.d/exim stop;
      sleep 10;
      killall -9 exim eximd
      sleep 5;

      #clean out the mail queue
      find /var/spool/exim -mindepth 2 -type f -exec rm -rfv ;

      #clean out the mail db files
      find /var/spool/exim/db -type f -exec rm -rvf ;

      /etc/init.d/exim restart









      share|improve this question













      I use the following command to delete the exim mail queues



      exiqgrep -i | xargs exim -Mrm


      or



      # following commands seems to work faster compared to the above.
      exim -bpru | awk 'print $3' | xargs exim -Mrm


      But the above commands do not work when the mail queue size is more than 100,000. It get stuck. So, I am using the following script which works fine regardless of the number of mails in the queue.



      My question is, will it delete correctly ?



      /etc/init.d/exim stop;
      sleep 10;
      killall -9 exim eximd
      sleep 5;

      #clean out the mail queue
      find /var/spool/exim -mindepth 2 -type f -exec rm -rfv ;

      #clean out the mail db files
      find /var/spool/exim/db -type f -exec rm -rvf ;

      /etc/init.d/exim restart






      linux email exim cpanel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 19 '16 at 10:54









      Mani

      201817




      201817




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote













          I believe you are looking for this...



          service exim stop
          rm -fvr /var/spool/exim/input
          service exim restart


          However a slightly more sane method is to remove the messages on a per user basis...



          egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr 'n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" 'gsub("-[A-Z]$","");print$NF' | xargs exim -Mrm 





          share|improve this answer



























            up vote
            0
            down vote













            In addition, to delete the emails of a specific user:



            grep -lr 'user@domain.com' /var/spool/exim/input/ | 
            sed -e 's/^.*/([a-zA-Z0-9-]*)-[DH]$/1/g' |
            xargs exim -Mrm

            exim -bp |
            grep "user_email-account" |
            awk 'print $3' |
            xargs exim -Mrm





            share|improve this answer





























              up vote
              0
              down vote













              To remove all messages from the queue, enter:



              # exim -bp | awk '/^ *[0-9]+[mhd]/print "exim -Mrm " $3' | bash





              share|improve this answer










              New contributor




              Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

















                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264318%2fis-it-a-correct-way-to-clear-the-exim-mail-queue%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                I believe you are looking for this...



                service exim stop
                rm -fvr /var/spool/exim/input
                service exim restart


                However a slightly more sane method is to remove the messages on a per user basis...



                egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr 'n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" 'gsub("-[A-Z]$","");print$NF' | xargs exim -Mrm 





                share|improve this answer
























                  up vote
                  4
                  down vote













                  I believe you are looking for this...



                  service exim stop
                  rm -fvr /var/spool/exim/input
                  service exim restart


                  However a slightly more sane method is to remove the messages on a per user basis...



                  egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr 'n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" 'gsub("-[A-Z]$","");print$NF' | xargs exim -Mrm 





                  share|improve this answer






















                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    I believe you are looking for this...



                    service exim stop
                    rm -fvr /var/spool/exim/input
                    service exim restart


                    However a slightly more sane method is to remove the messages on a per user basis...



                    egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr 'n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" 'gsub("-[A-Z]$","");print$NF' | xargs exim -Mrm 





                    share|improve this answer












                    I believe you are looking for this...



                    service exim stop
                    rm -fvr /var/spool/exim/input
                    service exim restart


                    However a slightly more sane method is to remove the messages on a per user basis...



                    egrep -Rl "((`pwd | cut -d / -f3`|$(grep `pwd | cut -d / -f3` /etc/userdomains | cut -d : -f1 | tr 'n' '|' | sed 's/|$//g'))|/home/`pwd | cut -d / -f3`)|X-Failed-Recipients" /var/spool/exim/input --include='*-H' | awk -F "/" 'gsub("-[A-Z]$","");print$NF' | xargs exim -Mrm 






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 19 '16 at 11:29









                    rcjohnson

                    81049




                    81049






















                        up vote
                        0
                        down vote













                        In addition, to delete the emails of a specific user:



                        grep -lr 'user@domain.com' /var/spool/exim/input/ | 
                        sed -e 's/^.*/([a-zA-Z0-9-]*)-[DH]$/1/g' |
                        xargs exim -Mrm

                        exim -bp |
                        grep "user_email-account" |
                        awk 'print $3' |
                        xargs exim -Mrm





                        share|improve this answer


























                          up vote
                          0
                          down vote













                          In addition, to delete the emails of a specific user:



                          grep -lr 'user@domain.com' /var/spool/exim/input/ | 
                          sed -e 's/^.*/([a-zA-Z0-9-]*)-[DH]$/1/g' |
                          xargs exim -Mrm

                          exim -bp |
                          grep "user_email-account" |
                          awk 'print $3' |
                          xargs exim -Mrm





                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            In addition, to delete the emails of a specific user:



                            grep -lr 'user@domain.com' /var/spool/exim/input/ | 
                            sed -e 's/^.*/([a-zA-Z0-9-]*)-[DH]$/1/g' |
                            xargs exim -Mrm

                            exim -bp |
                            grep "user_email-account" |
                            awk 'print $3' |
                            xargs exim -Mrm





                            share|improve this answer














                            In addition, to delete the emails of a specific user:



                            grep -lr 'user@domain.com' /var/spool/exim/input/ | 
                            sed -e 's/^.*/([a-zA-Z0-9-]*)-[DH]$/1/g' |
                            xargs exim -Mrm

                            exim -bp |
                            grep "user_email-account" |
                            awk 'print $3' |
                            xargs exim -Mrm






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 15 at 12:28









                            exhuma

                            13818




                            13818










                            answered Feb 23 '16 at 10:33









                            A Yashpal

                            765




                            765




















                                up vote
                                0
                                down vote













                                To remove all messages from the queue, enter:



                                # exim -bp | awk '/^ *[0-9]+[mhd]/print "exim -Mrm " $3' | bash





                                share|improve this answer










                                New contributor




                                Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.





















                                  up vote
                                  0
                                  down vote













                                  To remove all messages from the queue, enter:



                                  # exim -bp | awk '/^ *[0-9]+[mhd]/print "exim -Mrm " $3' | bash





                                  share|improve this answer










                                  New contributor




                                  Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.



















                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    To remove all messages from the queue, enter:



                                    # exim -bp | awk '/^ *[0-9]+[mhd]/print "exim -Mrm " $3' | bash





                                    share|improve this answer










                                    New contributor




                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    To remove all messages from the queue, enter:



                                    # exim -bp | awk '/^ *[0-9]+[mhd]/print "exim -Mrm " $3' | bash






                                    share|improve this answer










                                    New contributor




                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    share|improve this answer



                                    share|improve this answer








                                    edited 3 mins ago









                                    slm♦

                                    242k66501669




                                    242k66501669






                                    New contributor




                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    answered 10 mins ago









                                    Sheraz Chaudhery

                                    1




                                    1




                                    New contributor




                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





                                    New contributor





                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    Sheraz Chaudhery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f264318%2fis-it-a-correct-way-to-clear-the-exim-mail-queue%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Bahrain

                                        Postfix configuration issue with fips on centos 7; mailgun relay