Delete 30GB of files in a mailbox

9 posts / 0 new
Last post
#1 Tue, 09/18/2012 - 02:13

Delete 30GB of files in a mailbox


Because of this issue ( where emails are being sent to root every time a cron run, I now have over 30GB worth of emails in my inbox! I never used the email address of the root account so I didn't know until I have a space problem.

How do i delete all these files? I tried something like rm - .. find -delete .. and they dont seem to work and just stop working without any files being deleted. I couldn't even count how many files are in the with ls -1R | wc -l

I now have to use PHP to delete them but it takes over a minute to delete just 1500 files :(.

Any help would be appreciated.

Thank you.


Tue, 09/18/2012 - 03:53
ronald's picture

you can navigate into the directory holding your emails and issue something like: rm -f *
30GB will still take some time

Tue, 09/18/2012 - 05:37

I did through ssh and it just freezes ..

Tue, 09/18/2012 - 09:09

30GB of email is quite a bit :-)

After a few thousand files, globbing characters such as "*" will usually stop working (delivering "Argument list too long" errors).

For that number of files, which are all in a single dir -- it really could take several hours.

I would probably start with this command:

find /root/Maildir/new | xargs rm

If, after a few hours, you don't think it's making a change in the total number of files... you could always try using this:

rm -rf /root/Maildir/new

If that doesn't work either -- if you run the command "dmesg", do you see any errors towards the end?


Tue, 09/18/2012 - 09:30

Will try that and get back to you. Thank you, Eric.

Fri, 09/21/2012 - 01:55

For like 8 hours of running the command, 2 GB of files were deleted with rm -rf /root/... This is going to take many days :(

I ran dmesg and i dont think there is any error messages.

Sun, 07/28/2013 - 18:00

webmin > servers > postfix > user mailboxes > module config:

set "Show button to delete entire mailbox?" to yes

go to user mailboxes, click root, then "delete mailbox", are you sure etc..

return to module config via user mailboxes and switch off "Show button to delete entire mailbox?"

Mon, 07/29/2013 - 02:41 (Reply to #7)

Thanks! But I think I ended up using PHP to delete like 500 files at time or something.

Wed, 08/14/2019 - 02:33

I just had the same issue but the folder was 2.4GB.

Using the webmin filemanager:

I renamed /root/maildir/cur to /root/maildir/cur.old

recreated /root/maildir/cur 700

deleted /root/maildir/cur.old

Whole job took less than 3 minutes.

Topic locked