It always
seems to happen late on a Saturday night. You're getting paged
because a partition on one of the servers (probably the mail
server) is dangerously close to full.
Obviously, running a df
will show what's left:
rob@magic:~$ df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/sda1 7040696 1813680 4863600 27% /
/dev/sda2 17496684 13197760 3410132 79% /home
/dev/sdb1 8388608 8360723 27885 100% /var/spool/mail
But you already knew that the mail
spool was full (hence, the page that took you away from an
otherwise pleasant, non-mailserver related evening). How can
you quickly find out who's hogging all of the space?
Here's a one-liner that's handy
to have in your .profile:
alias ducks='du -cks * |sort -rn |head -11'
Once this alias is in place, running
ducks in any directory will show
you the total in use, followed by the top 10 disk hogs, in
descending order. It recurses subdirectories, which is very
handy (but can take a long time to run on a heavily loaded
server, or in a directory with many subdirectories and files
in it). Let's get to the bottom of this:
rob@magic:~$ cd /var/spool/mail
rob@magic:/var/spool/mail$ ducks
8388608 total
1537216 rob
55120 phil
48800 raw
43175 hagbard
36804 mal
30439 eris
30212 ferris
26042 nick
22464 rachael
22412 valis
Oops! It looks like my mail spool
runneth over. Boy, I have orders of magnitude more mail than
any other user. I'd better do something about that, such as
appropriate new hardware and upgrade the /var/spool/mail
partition. ;)
As this command recurses subdirectories,
it's also good for running a periodic report on home directory
usage:
root@magic:/home# ducks
[ several seconds later ]
13197880 total
2266480 ferris
1877064 valis
1692660 hagbard
1338992 raw
1137024 nick
1001576 rob
925620 phil
870552 shared
607740 mal
564628 eris
For running simple spot checks while
looking for disk hogs, ducks can
save many keystrokes (although if we called it something like
ds, it would save even more, but
wouldn't be nearly as funny.)
Showing messages 1 through 11 of 11.
- How about xdu?
2004-01-23 16:04:04 riddet
[Reply
| View]
How come nobody has mentioned xdu?
Very useful for detecting disk hogs graphically.
http://sd.wareonearth.com/~phil/xdu/
- another (better?) way to do this
2003-03-19 15:29:31 anonymous
[Reply
| View]
du -x --max-depth=1 |sort -n
This will limit it to the current filesystem.
I think it will only work on GNU du
- another (better?) way to do
this
2003-07-26 16:23:13 anonymous
[Reply
| View]
Or:
ls -a | grep -v -e '^\.\+$' | xargs -i du -cks {} |sort
-rn |head -11
or even:
ls -a | grep -v -e '^\.\.$' | xargs -i du -cks {}
|sort -rn |head -11
which has the nice side effect of showing the total
size of the directory (obviously the contents of the
directory are bigger than the largest file in the
directory).
- another (better?) way to do
this
2003-05-12 11:05:22 anonymous
[Reply
| View]
I would agree that this is better,
as this version will catch dotfiles and dotdirectories,
while the book one will not.
I had completely missed that my .wine directory was
taking up the lions share of my home directory with
my usual "du -s * | sort -rn | head" command.
|