df difference from du

df difference from du

Post by av » Wed, 05 Jun 2002 01:33:24



I have process that works for days and produces log file.
Every midnight the log file is closed for the current day and new one
for the new day creates. I delete the old logs.
This procedure works on about 10 log files that grow to 10-300MB.
The problem appears is after big log files that been created and
deleted, the df still see them holding the avaiable space and the du
-ks doesnt see them.
I got to situation that the difference between the df and du was over
800MB
I know how df and du work, but my problem is I cant close this process
and free the space.

Is there a possibility to remove these deleted files (removed files
that have an inode of 0) while df sees and du skips without killing
the process?

Currently, I kill the process every time the filesystem become almost
full to prevent any system problems.

I will be happy for better solution,
Thanks,
Avi

 
 
 

df difference from du

Post by Darren Dunha » Wed, 05 Jun 2002 02:23:59



> I know how df and du work, but my problem is I cant close this process
> and free the space.
> Is there a possibility to remove these deleted files (removed files
> that have an inode of 0) while df sees and du skips without killing
> the process?

Don't try to 'remove' it while it is open.  You've already seen that it
doesn't work.  If you don't need the data, truncate it.  
cp /dev/null /file  or
cat /dev/null > /file

Both should reduce the number of blocks allocated to the file to zero.
If the process is still writing, it will start to fill up again, but
what else would you expect?

Quote:> Currently, I kill the process every time the filesystem become almost
> full to prevent any system problems.

That's the best way to do it.

--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

df difference from du

Post by Barry Margoli » Wed, 05 Jun 2002 02:56:20




Quote:>Don't try to 'remove' it while it is open.  You've already seen that it
>doesn't work.  If you don't need the data, truncate it.  
>cp /dev/null /file  or
>cat /dev/null > /file

Or just:

Quote:> /file
>Both should reduce the number of blocks allocated to the file to zero.
>If the process is still writing, it will start to fill up again, but
>what else would you expect?

Another problem is that it will keep writing at the same location in the
file, so it will have a huge gap of null bytes at the beginning, unless it
opened the file in O_APPEND mode.

Quote:>> Currently, I kill the process every time the filesystem become almost
>> full to prevent any system problems.

>That's the best way to do it.

It will also solve the file location problem I mentioned.

Another solution is to use syslog rather than writing directly to the
file.  After removing the file, send SIGHUP to syslogd and it will close
and re-open the log file.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. Differences between df and du -s

Hi,

I've had this strange problem for which I haven't been able to find an
explanation:

With "df", I saw my partition in /dev/hda7, mounted on /var, which had all
its capacity (250 MB) used. I have a MySQL database installed (it uses the
/var directory), and it had stopped working.

Hoewever, changing to this directory, and doing du -s, showed that only 23
or 24 MB were allocated to the filesystem. I also looked manually to the
list of files, and found nothing. I tried to run e2fsck, but as the
partition was mounted, it didn't work. Trying to unmount it didn't work
either, as there was a message saying that the drive was being used.

Finally, after rebooting with shutdown -rF, things were back to normal, so
"df" showed me the same disk capacity in use as du. I didn't have the choice
to see the check running, as it is a remote system which I access via
telnet.

Where could the problem be?
What tools could I use to find the problem if it happens again?

Thanks in advance.

2. NE2000 compatible - No Traffic

3. du and df diskspace differences

4. It Doesn't Matter (much) If Sun Doesn't "Support" Dataless

5. Difference between df and du command

6. Ftp connection SunOS <--> 2.0.17 really slow, why?

7. df, du and ls differences

8. preserving MS Word formatting in Linux

9. What's the difference between du and df commands

10. Why difference between du and df commands

11. Difference between df -k and df -b

12. what units should df and du use?

13. results of df and du don't match