0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@123 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 31G 6.8G 82% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 273M 3.6G 7% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup [root@123 /]# du -h / --max-depth=1 132K /tmp du: cannot access ‘/proc/15315/task/15315/fd/4’: No such file or directory du: cannot access ‘/proc/15315/task/15315/fdinfo/4’: No such file or directory du: cannot access ‘/proc/15315/fd/4’: No such file or directory du: cannot access ‘/proc/15315/fdinfo/4’: No such file or directory 0 /proc 4.0K /home 273M /run 65M /boot 1.7G /usr 4.0K /srv 23M /etc 407M /opt 0 /dev 152K /root 16K /lost+found 1.4G /123 187M /var 4.0K /media 0 /sys 4.0K /mnt 4.0G / [root@123 /]# |
定时任务中有这样一个脚本:
0 |
cat /dev/null > /opt/tomcat/logs/catalina.out |
修复后:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@123 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 12G 26G 31% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.3M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup [root@123 ~]# du -h / --max-depth=1 140K /tmp du: cannot access ‘/proc/3615/task/3615/fd/4’: No such file or directory du: cannot access ‘/proc/3615/task/3615/fdinfo/4’: No such file or directory du: cannot access ‘/proc/3615/fd/4’: No such file or directory du: cannot access ‘/proc/3615/fdinfo/4’: No such file or directory 0 /proc 4.0K /home 8.3M /run 65M /boot 1.7G /usr 4.0K /srv 23M /etc 8.3G /opt 0 /dev 156K /root 16K /lost+found 1.2G /123 183M /var 4.0K /media 0 /sys 4.0K /mnt 12G / [root@iZ23t9k0luhZ ~]# |
可能原因:SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/
(1)
When you open a file, you get a pointer. Subsequent writes to this file
references this file pointer. The write call does not check to see if the file
is there or not. It just writes to the specified number of characters starting
at a predetermined location. Regardless of whether the file exist or not, disk
blocks are used by the write operation. SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/The df command reports the number of disk blocks used while du goes through the
file structure and and reports the number of blocks used by each directory. As
far as du is concerned, the file used by the process does not exist, so it does
not report blocks used by this phantom file. But df keeps track of disk blocks
used, and it reports the blocks used by this phantom file.
以及leolein朋友的回复:
谢谢,就是这个原因。
我因为磁盘快满了就删除了一些过期的文件,可能应用程序还在使用这些文件句柄,所以导致了我说的问题。
我把所有的应用程序都停止后,du和df的结果就大致相同了SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/(2):
This section gives the technical explanation of why du and df sometimes report
different totals of disk space usage.SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/When a program that is running in the background writes to a file while the
process is running, the file to which this process is writing is deleted.
Running df and du shows a discrepancy in the amount of disk space usage. The
df command shows a higher value. SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/
参考1:http://www.chinaunix.net/old_jh/6/465673.html
参考2:http://blog.itpub.net/26230597/viewspace-1242675
其他参考:http://www.cnblogs.com/heyonggang/p/3644736.htmlSourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/
SourceByrd's Weblog-https://note.t4x.org/error/df-diff-du/