Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Feb 2004
    Location
    Montreal
    Posts
    63

    Lightbulb How to delete all mails on server older than X years..

    Hi,

    Is there a script for whm that deletes all mails older than XX years for all accounts on the server ?

    Thanks !

  2. #2
    Member WebScHoLaR's Avatar
    Join Date
    Dec 2005
    Location
    Planet Earth
    Posts
    504

    Default

    If the files haven't been accessed and have the older timestamp then you can delete the emails using find command.We will look for any files that are more than 2 years (2*365=730 days) old. A simpler command can be as but it needs to be further modified as per requirements.

    find /home/*/mail -type f -mtime +730 | xargs rm -vf

    You can set it as cron. Before running the command you should see what find command finds:

    find /home/*/mail -mtime +730 > /home/emails.list

    Regards,
    WebScHoLaR

    WebHosting Blog: http://WebScHoLaR.net

Similar Threads & Tags
Similar threads

  1. Email aging - Delete emails older than.. on server
    By ramystyle in forum E-mail Discussions
    Replies: 1
    Last Post: 01-21-2011, 12:39 PM
  2. how to auto delete all emails older than 2 years (cpanel)? Any scripts?
    By ramystyle in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 06-14-2009, 12:37 PM
  3. Delete mail queue older than 3 days
    By jameshsi in forum cPanel and WHM Discussions
    Replies: 10
    Last Post: 10-07-2005, 07:34 AM
  4. Delete messages in queue older than xx days ?
    By pguy in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 02-02-2004, 02:40 PM
  5. How to delete email that is older than x amount of days?
    By Roberto in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 01-09-2004, 06:55 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube