Need guidance; email account sizes

I am surprised with how fast my hard drive is filling up with email for my clients. Is there a way for me to check on which accounts are my “saving everything under the sun in their inbox” culprits?

Keith.

1 Like

You could try just looking on the filesystem to see which domain/user is using the most space.

Become root (if you’re not already) with “sudo su -”.
Next, cd into the top of the mailbox dir tree, “cd /home/user-data/mail/mailboxes
And run this command from that directory, “du -sh */*

That will give you a listing of size and domain/email-address.

1 Like

thank you.
the DU command works really nicely for each domain but not so much per subdirectory. Would have been handy to be able to tell the user, “hey there, you have a huge Sent folder; any chance you do some archiving?”.
Glad that the culprit domain only has two users and one of them doesn’t really use it.

Thanks again,
Keith.

To be able to get the size of sub-directories I would run the following command:

du -h */* | grep -E '[0-9]{2,}M|[0-9]{1,}G' | sort -u -t$'\t' -k1,1 | sort -t$'\t' -k2

Command breakdown:

  1. List all directories and sub-directories at the current location.
du -h */*
  1. Only output directories larger than 10 megabytes.
  • You can change the size limit by changing the numbers inside the curly brackets {}.
grep -E '[0-9]{2,}M|[0-9]{1,}G'
  1. Sort out duplicates by checking if the directory size is the same.
  • This is not fail proof, it might remove directories from different users if the directory size is the same.
sort -u -t$'\t' -k1,1
  1. Sort the final output by the directory name.
sort -t$'\t' -k2

use for subfolders:
ncdu