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!

SOLVED Cron To Remove Emails Older Than One Hour

Discussion in 'E-mail Discussion' started by wynonnal, Oct 23, 2017.

  1. wynonnal

    wynonnal Registered

    Joined:
    Oct 23, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    California
    cPanel Access Level:
    Root Administrator
    I am currently using a cron script that scans a specific email address for a payment notification (this is for a membership website - the cron script is essential for sending emails and verifying membership status). The problem I am experiencing is that if there are too many emails in the inbox the script times out and does not complete its task.

    The work around I am currently using removes any emails in the new and cur folders that are older than a day.

    The cron script I have runs once a day and looks like this:
    /bin/find /home/user/mail/domain/emailname/new ! -mtime -0 -type f -exec rm {} \;
    /bin/find /home/user/mail/domain/emailname/cur! -mtime -0 -type f -exec rm {} \;

    I need to narrow down the time criteria to remove any emails older than one hour.

    I've look through older threads and on posts elsewhere and haven't found anything else that works.

    Any suggestions?
     
  2. jlucho

    jlucho Active Member

    Joined:
    Aug 5, 2006
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    156
    dear

    add you script of clean , to :
    /etc/cron.hourly
     
    #2 jlucho, Oct 23, 2017
    Last edited by a moderator: Oct 23, 2017
  3. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,651
    Likes Received:
    73
    Trophy Points:
    328
    cPanel Access Level:
    Root Administrator
    You're looking for the -mmin parameter to find instead of -mtime.

    You will have to specify in minutes, i.e. -mmin -60 for this to work
     
  4. wynonnal

    wynonnal Registered

    Joined:
    Oct 23, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    California
    cPanel Access Level:
    Root Administrator
    This worked! Thank you so much - I did not have luck with mmin before but it was because I was setting the value to -0 but now that makes sense.

    Thank you again!
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,672
    Likes Received:
    1,788
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm glad to see the previous posts helped. I've marked this thread as solved.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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