Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Setup cron to delete Exim Mail Queue

Discussion in 'E-mail Discussion' started by Rajesh Chauhan, Jan 18, 2019.

  1. Rajesh Chauhan

    Rajesh Chauhan Member

    Joined:
    Jan 18, 2016
    Messages:
    23
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    I have a server which is used to send lots of emails (Most system generated) I want to setup cron to delete all Exim Email Queue every day. How do I set up this thing in an easy way?
     
  2. Eminds

    Eminds Well-Known Member

    Joined:
    Nov 10, 2016
    Messages:
    315
    Likes Received:
    29
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    The emails that you are talking about must be the LFD notification emails , so instead of deleting them , check them.there might be some issue that needs to be addressed OR you can simply disable those LFD notifications from firewall option in WHM.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,484
    Likes Received:
    187
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    To answer your question directly, this command

    exim -bpru | awk '{print $3}' | xargs exim -Mrm

    Will delete all the messages in the queue, but it would delete a message even if it was just put in the queue a minute ago.

    You might be better off changing the exim settings to dump messages out of the queue after a day. You can set this in the advanced exim config editor under the RETRYBLOCK section.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Rajesh Chauhan

    Rajesh Chauhan Member

    Joined:
    Jan 18, 2016
    Messages:
    23
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Is there any commands line for the second option?
     
  5. GOT

    GOT Get Proactive! PartnerNOC

    Joined:
    Apr 8, 2003
    Messages:
    1,484
    Likes Received:
    187
    Trophy Points:
    193
    Location:
    Chesapeake, VA
    cPanel Access Level:
    DataCenter Provider
    No the second option is reconfiguring the section in the exim conf.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,464
    Likes Received:
    505
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello @Rajesh Chauhan

    While the solution provided by @GOT will work, I do need to point out this is a terrible idea. Rather than delete potentially valid email (that your clients may be need) I'd recommend identifying the cause of the system generated emails as well as WHY they're sitting in the mail queue.


    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    sparek-3 likes this.
  7. Rajesh Chauhan

    Rajesh Chauhan Member

    Joined:
    Jan 18, 2016
    Messages:
    23
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Is there any option to set this command to set on every day?
     
  8. kssuhesh

    kssuhesh Member

    Joined:
    Jan 11, 2009
    Messages:
    19
    Likes Received:
    5
    Trophy Points:
    128
    Location:
    Kochi
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You should add it in cron to run it everyday.

    First, you should check the reason for generating the mails and fix it. That is the good option than deleting the emails without checking it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. LucasRolff

    LucasRolff Well-Known Member

    Joined:
    May 27, 2013
    Messages:
    62
    Likes Received:
    48
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I remember once, people were complaining about the server using a lot of cached memory, they did a cronjob executing every hour, to drop caches... That was a super bad idea...

    Now, this will be another bad idea :) Please just fix your email instead of clearing the queue with a cron.

    Cronjobs are great, but never abuse them!
     
    rpvw and cPanelLauren like this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice