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.

crontab to remove email from a mailbox every 24 hrs?

Discussion in 'E-mail Discussions' started by estado3, Sep 30, 2006.

  1. estado3

    estado3 Member

    Joined:
    May 12, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    what is a simple cron tab to remove every 24 hrs emails in a mailbox called
    mailbox on path /.neomail/mailbox ?

    thanks
     
  2. dragonbooster

    dragonbooster Active Member

    Joined:
    Oct 4, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Following are the steps for setting up the cron to delete the mails from mailbox:

    create the file emptymail box
    cd /home/username/www
    pico emptymailbox
    type the following command in the file
    echo > /home/username/path to mailbox
    save your file
    chmod 755
    crontab -u username -e
    set the following cron
    0 0 * * * /home/username/www/emptymailbox
    save the file

    Please try this
     
  3. designeru

    designeru Well-Known Member

    Joined:
    Nov 2, 2005
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    6
    ... or a simpler solution...

    add to /etc/crontab

    0 0 * * * echo > /path_to_mailbox/
     
  4. yufool

    yufool Active Member

    Joined:
    Jan 24, 2004
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    or:

    simpler yet under cPanel, you can set aging to 1 day.
     
  5. dragonbooster

    dragonbooster Active Member

    Joined:
    Oct 4, 2006
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Thanks designneru and yufool for the simple solution.:)

    Creating a separate file option can be use to set the multiple rules at one place so no need to set the different cron for each action
     
  6. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    If you're using maildir rather than the older mailbox, you'll need something like this:

    find /.neomail/mailbox -type f -mtime +1 | xargs rm -f

    which will remove all email older than 1 day, probably more what you want rather than just throwing it all out.

    (Maildir email format stores mail as separate files, mailbox format stores mail concatenated all in one file)
     
Loading...

Share This Page