The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cron Job auto delete emails older than X days in a domain

Discussion in 'E-mail Discussions' started by ahyde, Oct 21, 2015.

  1. ahyde

    ahyde Registered

    Joined:
    Oct 21, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mexico
    cPanel Access Level:
    Website Owner
    Hi,
    I try to delete all email arrived of 1 month old of a specific domain with a cron job I tried with this commands:

    Code:
    /usr/bin/archivemail -quiet -delete -days 30 /home/USERNAME/mail/MYDOMAIN.COM/
    Code:
    find /home/USERNAME/mail/MYDOMAIN.COM/*/cur -type f -mtime +30 -exec rm -f {} \;
    Code:
    find /home/mail/MYDOMAIN.COM/*/ -quiet -delete -days 30
    Code:
    find  /home/mail/MYDOMAIN.COM/ -type f -mtime +7 -delete
    I have been reading a lot in internet, I read and search in this forum but nothing works for me.
    My host it a VPS of Godaddy I don't know if this influences in the command

    I read these entries previously and others from internet:
    Possible to auto delete old emails after x number of days?
    Deleting Mails with Cron ???

    Some errors sending to my email are with different commands:
    find: missing argument to `-exec'
    find: unknown predicate `--delete'
    find: `/home/mail/MYDOMAIN.COM/': No such file or directory
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. ahyde

    ahyde Registered

    Joined:
    Oct 21, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mexico
    cPanel Access Level:
    Website Owner
    Thank you for answer :) and yes I replace USERNAME and MYDOMAIN.COM as my user name and the domain what I want delete all emails. I read the entry but did not work, I'm so newbie and I don't understand a lot the commands but I try.

    The path what I think is the correc for me is (because I see the path in my host server):
    Code:
    /home/USERNAME/mail/MYDOMAIN.COM/*/
    because when I write the code previously put they don't send me error in the path, but in the command code after send me errors. I have been reading what mean each word in the commands but nothing I don't have idea why don't work :(
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Do you see any output if you manually enter the "find" command? Could you send me a private message of the exact command you are using?

    Thank you.
     
  5. ahyde

    ahyde Registered

    Joined:
    Oct 21, 2015
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Mexico
    cPanel Access Level:
    Website Owner
    Sorry but I can't send PM, this error out:
    Untitled.png

    But anyway this is the code that I wanted send you :)

    The path what I think is the correct is:
    Code:
    find /home/usernamehere/mail/example.com/*
    but the commands I don't know why don't works :(

    well, this are the commands what I used :

    Code:
    find /home/mail/example.com/*/ -quiet -delete -days 30
    find  /home/mail/example.com/ -type f -mtime +7 -delete
    –quiet –delete –months 1 /home/iqmarkethink/mail/example.com/*/ 
    My user is:usernamehere
    and my domain: example.com

    Really thanks again for you help, I'm soooooooo newbie in this :oops:
     

    Attached Files:

    #5 ahyde, Oct 30, 2015
    Last edited by a moderator: Oct 30, 2015
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Your "find" commands do not appear to use the correct paths. It's searching in "/home/mail" which is not a valid directory location.

    Thank you.
     
  7. mageshm

    mageshm Well-Known Member

    Joined:
    Apr 17, 2014
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Chennai, INDIA
    cPanel Access Level:
    DataCenter Provider
Loading...

Share This Page