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.

Email users don't empty their trash!

Discussion in 'E-mail Discussions' started by rfrench10, Jan 1, 2005.

  1. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    :eek: Anyone got a good solution for emptying the email trash? I have several large users that don't clear out their trash for weeks at a time. Those boxes accumulate 100,000 emails easily! Is there anything out there that will automatically clean out the user's trash email??? :confused:
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Just delete the neomail-trash files either manually or with a script which can be run as a cron job.

    Or just leave them and when they run out of space they have to empty it themselves.
     
  3. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    I manually delete the individual trash mail boxes weekly now. Just wondering if there was anything out there to do it without manual intervention. thanks,
    :(
     
  4. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Might ask Squirrel to write a script as he has many others that are quite helpful. ;)
    http://www.premierwebsitesolutions.com/scripts/
     
  5. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    clean mail trash

    here is a script I put together, Use at your own risk.

    The script will delete all INBOX.Trash, neomail-trash and sent-mail
    change the for loop if you desire.

    You could also write the output of the first find to a file if you would like to monitor.

    Code:
    #!/bin/sh
    
    # cleanmailtrash.sh
    # Clean out those users trashcans
    
    cd /home
    for FILE in INBOX.Trash neomail-trash sent-mail
    do
            #find */mail/ -name $FILE -type f -exec ls -al {} \;
            find */mail/ -name $FILE -type f -exec rm {} \;
    done
    
    #
    # End
    #
     
  6. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    That script looks good to me, but I wouldn't remove the sent-mail files because on one of my accounts my email is practically never used, so I use neomail to check it and send replies, and I wouldn't want my replies deleted unless I delete them myself which would put them in the trash. ;)
     
  7. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
  8. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    I agree with the post above, I copied a script I used for a user that wanted all their files removed and left that in there.
     
  9. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    Thank you all for your responses. Will this also clear the squirelmail trash?
     
  10. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Yes. That's what the INBOX.Trash is in the list for. That's the squirrelmail trash file.
     
  11. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    Can't get the script to run either as a cron or in ssh as root. Any suggestions???
    I keep getting 'command not found'
    I put the script in /scripts/scripts/cleanmailtrash.sh

    Help me ... I'm drowning in a sea of email (trash)

    Thanks for any help on this.
     
  12. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    the script should be run as root
    you can place it anywhere

    make sure you chmod 755 the script or start using

    sh cleanmailtrash.sh
     
  13. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    I had permissions set to 755 and this is the output I keep getting:

    sh /scripts/scripts/cleanmailtrash.sh
    no such file or directory

    Thanks again for the help.
     
  14. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    that sounds like the script is not in /scripts/scripts

    do a
    ls /scripts/scripts/cleanmailtrash.sh
    to see if that is indeed where you put it.
     
  15. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    ls /scripts/scripts/cleanmailtrash.sh
    produces the following:
    /scripts/scripts/cleanmailtrash.sh*
     
  16. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    I just did a quick test, ssh'd in as root, created the script right there switching the comment tag from the list to the delete line, then ran it with "sh cleanmailtrash.sh" and it gave me a huge list of trash files.

    It should work. Did you create the script then upload it? Did you upload it in ascii or binary mode? Needs to be ascii mode if you upload it.
     
  17. Shrek

    Shrek Active Member

    Joined:
    Sep 6, 2004
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Arkansas, USA
    I tried it just for the heck of it and it worked like a charm. :D
     
  18. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    I deleted the files I uploaded the other day and specifically uploaded a new copy in ASCII and lo and behold it worked! I'll bet the ftp program didn't autoselect ASCII the first time. Thanks again everyone! Such a stupid error on my part and one that has bitten me before... I should have thought of the ASCII upload error.
     
  19. rfrench10

    rfrench10 Well-Known Member

    Joined:
    Feb 19, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    New York
    OOPPS, when run as root at ssh it runs fine but when run as cron it give the following errors:
    find: */mail/: No such file or directory
    find: */mail/: No such file or directory

    Any suggestions?

    thanks,
     
  20. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    Change the script to remove the

    cd /home

    then in the find command line put

    find /home/*/mail/

    that should do it.


    Although the cd /home should work.
     
Loading...

Share This Page