Koozali.org: home of the SME Server
Contribs.org Forums => General Discussion => Topic started by: gbentley on February 07, 2017, 09:39:12 AM
-
Hi All,
I am trying to sort /home/e-smith/files/users into something sensible so that I can send out an automated monthly summary of size.
Here's my feeble effort so far...
# du -h --max-depth=1 | sort -n -r > totals.txt
The problem with this is that the outputted list is a little jumbled...
447M
8.0K
7.1G
So now I need to get all those user with 'G' at the top of the list, then 'M' and if I could remove the du total entirely that would be good.
Any tips?
Thanks :)
-
You need to remove the -h for sort -n to be effective.
Here's a small script I use for this:
https://wikit.firewall-services.com/doku.php/tuto/ipasserelle/divers/stat_espace_par_utilisateur
use it as perl quota.pl > totals.csv
You can then open it with Excel or Calc if you want to format it further. It'll print for each users the space used by their mailbox, their home dir, and the total space (email + home + files created in ibays/shared folders)
-
Thanks for this. I'm only interested in the size of their email directories though. Will see if I can mod this to do that :)
I also need to run this monthly. Is it equally possible to execute a perl job from crontab as you can with a shell script?
-
usually I use
du -s -m * | sort -nr | head
to find the biggest/heaviest dirs
-
use it as perl quota.pl > totals.csv
# perl quota.pl
Can't locate quota.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at quota.pl line 3.
BEGIN failed--compilation aborted at quota.pl line 3.
-
This script requires perl-Quota. There's one RPM in fws repo
-
This script requires perl-Quota. There's one RPM in fws repo
Thanks :)
Was kinda hoping to do this with stock tools etc and have to have units that users understand ie GB, MB etc
Maybe grepping G and M is separate passes...
-
Was kinda hoping to do this with stock tools etc and have to have units that users understand ie GB, MB etc
Post-process the numbers after the sort has been done.
Or teach your users some basic arithmetic :-)