Re: How to find files that are eating up disk space

2008-12-17 Thread Cliff Addy
Use df to report disk usage.  Sitting in /, for example, df -sm bin
will tell you the disk usage in megs in the bin directory, df -sm *
will do the same for each file/dir in /

man df for the whole story

Cliff


John Almberg wrote:
 Here is another newbie question that is driving me crazy, but is
 probably a laughable situation to an experienced admin...

 I've got a smallish server that is suddenly out of disk space in the
 '/' partition.

 Probably some log files have gotten out of hand. I am going to start
 looking for the culprits by hand... basically inspecting sub
 directories, but there must be a better way!

 Is there a command line tool that will help me figure out where the
 problem is?

 Even better, is there a way to proactively monitor the file system, so
 I can fix problems before I start getting 'out of disk space' errors?

 Any hints, much appreciated.

 -- John

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 freebsd-questions-unsubscr...@freebsd.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread Cliff Addy
Uh, that should be du not df :)

--


Use df to report disk usage.  Sitting in /, for example, df -sm bin
will tell you the disk usage in megs in the bin directory, df -sm *
will do the same for each file/dir in /

man df for the whole story

Cliff


John Almberg wrote:
 Here is another newbie question that is driving me crazy, but is
 probably a laughable situation to an experienced admin...

 I've got a smallish server that is suddenly out of disk space in the
 '/' partition.

 Probably some log files have gotten out of hand. I am going to start
 looking for the culprits by hand... basically inspecting sub
 directories, but there must be a better way!

 Is there a command line tool that will help me figure out where the
 problem is?

 Even better, is there a way to proactively monitor the file system, so
 I can fix problems before I start getting 'out of disk space' errors?

 Any hints, much appreciated.

 -- John

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 freebsd-questions-unsubscr...@freebsd.org




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


How to find files that are eating up disk space

2008-12-17 Thread John Almberg
Here is another newbie question that is driving me crazy, but is  
probably a laughable situation to an experienced admin...


I've got a smallish server that is suddenly out of disk space in the  
'/' partition.


Probably some log files have gotten out of hand. I am going to start  
looking for the culprits by hand... basically inspecting sub  
directories, but there must be a better way!


Is there a command line tool that will help me figure out where the  
problem is?


Even better, is there a way to proactively monitor the file system,  
so I can fix problems before I start getting 'out of disk space' errors?


Any hints, much appreciated.

-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread Wojciech Puchar

why not

du|sort -r|head -20

and you get 20 largest


I should probably have mentioned that what I currently do is run

du -h -d0 /

and gradually work my way down the tree, until I find the directory that is 
hogging disk space. This works, but is not exactly efficient.


-- John
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread John Almberg



Is there a command line tool that will help me figure out where the
problem is?


 I should probably have mentioned that what I currently do is run

du -h -d0 /

 and gradually work my way down the tree, until I find the
 directory that is hogging disk space. This works, but is not
 exactly efficient.


-d0 limits the search to the indicated directory; i.e. what
you can see by doing ls -al /.  Not superior to ls -al / and
using the Mark I eyeball.


sorry... I meant du -h -d1 directory


What (I think) you want is du -x -h /: infinite depth, but do
not cross filesystem mount-points.  This is still broken in that it
returns a list where the numbers are in a fixed-width fiend which
are visually distinguished only by the last letter.
Try this:

du -x /

and run the resu;ts through sort:

sort -nr

and those results through head:

head -n 20


Thanks to everyone that suggested this. A much faster way to find the  
big offenders





I have a cron job which does this for /usr and e-mails me the
output every morning.  After a few days, weeks at most, I know what
should be on that list ... and what shouldn't and needs
investigating.



And this is a great proactive measure. Thanks

-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread Karl Vogel
 On Wed, 17 Dec 2008 12:16:57 -0500, 
 John Almberg jalmb...@identry.com said:

J Is there a command line tool that will help me figure out where the [disk
J space] problem is?

   I run a script every night to handle this.  We have a few business
   divisions, and each division has several groups sharing files
   via Samba.  Each group likes its own space with permissions that
   prevent file diddling by other groups.  For example, division 3 is
   on drive /rd04, and has group directories /rd04/div3/engineering,
   /rd04/div3/finance, and /rd04/div3/marketing.

   /etc/periodic/daily/315.dirsize:

  #!/bin/ksh
  # dirsize: see how big each top-level group directory is.

  PATH=/bin:/usr/bin
  BLOCKSIZE=1m
  BLOCK_SIZE=1048576
  export PATH BLOCKSIZE BLOCK_SIZE

  umask 022
  tag=`basename $0`
  host=`hostname | cut -f1 -d.`

  logmsg () {
  logger -t $tag $@
  }

  # Check group areas on each drive.

  list='
  /rd01/div1
  /rd02/logs
  /rd03/div2
  /rd04/div3
  '

  (
  for dir in $list
  do
  logmsg checking size of $dir
  find $dir -type d -maxdepth 1 -print |
  tail +2 | sort | xargs du -s
  echo
  done

  ) | mailx -s $tag: directory sizes on $host root

  logmsg done
  exit 0

J Even better, is there a way to proactively monitor the file system, so I
J can fix problems before I start getting 'out of disk space' errors?

   This script is run hourly to tell me if we completely run out of room
   on something like /var or one of the user drives.  I run it on BSD and
   Solaris boxes, so I try to avoid GNU or OS dependencies.

   /usr/local/cron/checkdrives:

  #!/bin/ksh
  # checkdrives: send mail if a filesystem gets too full

  PATH=/bin:/usr/bin
  export PATH

  # Portability stuff here.

  case `uname -s` in
  SunOS)DF='/usr/xpg4/bin/df -F ufs -k' ;;
  FreeBSD)  DF='/bin/df -t ufs -k' ;;
  *)DF='df' ;;
  esac

  # Too full means 99% and less than 100 Mbytes available.

  str=`$DF |  # Check filesystem size ...
tail +2 | # ... skip the header ...
tr -d '%' |   # ... kill the percent sign ...
awk '$4  10  \
 $5 = 99 {print $6}'`# ... and print the filesystem.

  case X$str in
  X)  ;;
  *)  $DF $str | mailx -s 'Filesystem getting full' root ;;
  esac

  exit 0
  
-- 
Karl Vogel  I don't speak for the USAF or my company
It only rains straight down.  God doesn't do windows.   --Steven Wright
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread John Almberg
Is there a command line tool that will help me figure out where the  
problem is?


I should probably have mentioned that what I currently do is run

du -h -d0 /

and gradually work my way down the tree, until I find the directory  
that is hogging disk space. This works, but is not exactly efficient.


-- John
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread John Almberg


On Dec 17, 2008, at 1:53 PM, Karl Vogel wrote:


On Wed, 17 Dec 2008 12:16:57 -0500,
John Almberg jalmb...@identry.com said:


J Is there a command line tool that will help me figure out where  
the [disk

J space] problem is?

   I run a script every night to handle this.


snip



  exit 0

--
Karl Vogel  I don't speak for the USAF or my  
company




Very helpful. Thanks, Karl.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread Robert Huff

John Almberg writes:

   Is there a command line tool that will help me figure out where the  
   problem is?
  
  I should probably have mentioned that what I currently do is run
  
   du -h -d0 /
  
  and gradually work my way down the tree, until I find the
  directory that is hogging disk space. This works, but is not
  exactly efficient.

-d0 limits the search to the indicated directory; i.e. what
you can see by doing ls -al /.  Not superior to ls -al / and
using the Mark I eyeball.
What (I think) you want is du -x -h /: infinite depth, but do
not cross filesystem mount-points.  This is still broken in that it
returns a list where the numbers are in a fixed-width fiend which
are visually distinguished only by the last letter.
Try this:

du -x /

and run the resu;ts through sort:

sort -nr

and those results through head:

head -n 20


I have a cron job which does this for /usr and e-mails me the
output every morning.  After a few days, weeks at most, I know what
should be on that list ... and what shouldn't and needs
investigating.


Robert Huff

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


RE: How to find files that are eating up disk space

2008-12-17 Thread Barry Byrne
 

 -Original Message-
 From: owner-freebsd-questi...@freebsd.org 
 [mailto:owner-freebsd-questi...@freebsd.org] On Behalf Of John Almberg
 Sent: 17 December 2008 17:17
 To: freebsd-questions@freebsd.org
 Subject: How to find files that are eating up disk space
 
 Here is another newbie question that is driving me crazy, but is  
 probably a laughable situation to an experienced admin...
 
 I've got a smallish server that is suddenly out of disk space in the  
 '/' partition.
 
 Probably some log files have gotten out of hand. I am going to start  
 looking for the culprits by hand... basically inspecting sub  
 directories, but there must be a better way!
 
 Is there a command line tool that will help me figure out where the  
 problem is?
 
 Even better, is there a way to proactively monitor the file system,  
 so I can fix problems before I start getting 'out of disk 
 space' errors?
 
 Any hints, much appreciated.
reebsd-questions-unsubscr...@freebsd.org

As a start you might want to look at the 'du' command.

man du

for more info.

But for a quick start: 

du -x -d2 -h /

should give you some useful info.

You generally shouldn't have much writing to the / partition, unless you
haven't greated a separate /var partition, which is recommended.

 - barry

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to find files that are eating up disk space

2008-12-17 Thread Andy Greenwood
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

John Almberg wrote:
 Here is another newbie question that is driving me crazy, but is
probably a laughable situation to an experienced admin...

 I've got a smallish server that is suddenly out of disk space in the
'/' partition.

 Probably some log files have gotten out of hand. I am going to start
looking for the culprits by hand... basically inspecting sub
directories, but there must be a better way!

 Is there a command line tool that will help me figure out where the
problem is?

 Even better, is there a way to proactively monitor the file system, so
I can fix problems before I start getting 'out of disk space' errors?

 Any hints, much appreciated.


John,

try man du. It will give you file sizes of all the files in a directory
tree, which you can then pass to sort and head to pull out the biggest
offenders, like this

# cd /
# du | sort -rn | head -10

for monitoring my system, I use tripwire, but that might be a bit much
just for watching disk usage. Try putting a df -h in your periodic
scripts to have the output of that command mailed to you each day.
 -- John

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
freebsd-questions-unsubscr...@freebsd.org

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklJOE0ACgkQEStKVA82Z+1tNgCdHSAYcm5A6sTjbjjHmzL3ynS2
C+0Anim0sf0yIz/l7TVNtdA5a5JbM+Jz
=xetm
-END PGP SIGNATURE-

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org