On Wed, Apr 26, 2000 at 11:12:18PM -0500, w trillich wrote:
> okay. it's my fault. i let the log file get huge--but deleting
> it doesn't recover the space on the partition!

Common mistake.

A file under Linux and Linux-like operating systems isn't deleted until
all filehandles to it are closed (I think).  Deleting a large file to
free space is often the wrong thin to do.  You've removed your ability
to access and modify the data, but you haven't done anything to the data
itself.

Better solution:

 - "empty" the file:  cat /dev/null > really-big-file

 - Find out who/what is using it:  fuser really-big-file

 - Kill that process -- fuser offers this through "-k"

 - If the process is a system log, restart it.

Better, use a facility like logrotate to handle this process for you.

Usually you can zero out a file without going through the kill stages --
most logs fill relatively slowly.


> after checking error.log to see if any useful info was in
> there (yeah, right), i do:
>       # df
>       Filesystem           1k-blocks      Used Available Use% Mounted on
>       /dev/hda1               101075     47411     48445  49% /
>       /dev/hda7              2695175    599462   1956351  23% /usr
>       /dev/hda6               987220    936228         0 100% /var
>       # cd /var/log/apache
>       # ls -l error.log
>       -rw-r--r-- 1 www-data www-data 437281392 Apr 26 22:00 apache/error.log
> (cool! 437 [decimal] megabytes in one text file!)
>       # rm error.log
>       # ls -l error.log
>       ls: error.log: No such file or directory

[...]

> now we should have over half our /var partition free again, right?
> 
>       # df
>       Filesystem           1k-blocks      Used Available Use% Mounted on
>       /dev/hda1               101075     47411     48445  49% /
>       /dev/hda7              2695175    599462   1956351  23% /usr
>       /dev/hda6               987220    936228         0 100% /var
>       # df -m
>       Filesystem           1M-blocks      Used Available Use% Mounted on
>       /dev/hda1                   99        46        47  49% /
>       /dev/hda7                 2632       585      1910  23% /usr
>       /dev/hda6                  964       914         0 100% /var
> 
> i'm guessing that another process actually has the file open?
> which one--or how could i find that out, myself?

    fuser -mv /mount/point

...will show all open process (and files) on a mount point.

You can also go through the /proc filesystem process list and look for
open filehandles with odd characteristics.  I forget what a deleted file
looks like, but it ain't normal <g>

    ls -l /proc/[0-9]*/fd/*

-- 
Karsten M. Self <kmself@ix.netcom.com>           http:/www.netcom.com/~kmself
    What part of "Gestalt" don't you understand?
    http://gestalt-system.sourceforge.net/
GPG fingerprint: F932 8B25 5FDD 2528 D595  DC61 3847 889F 55F2 B9B0

Attachment: pgpybImI8h2CZ.pgp
Description: PGP signature

Reply via email to