Thursday, May 2, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 10665  / 1 Year ago, sat, november 26, 2022, 5:30:30

When I execute the command df -h /tmp it says disk utilization is 100%, but when it try du -sh /tmp it says disk utilization is 2%.



I want to know why these commands shows different output, how these two commands work and what is the solution to this problem.



Context: /tmp is installed on it own file system. I am using Ubuntu 12.04 server edition on my VPS account. Due to this problem utilization of /tmp 100% according to df some programs complain about free space in /tmp.


More From » command-line

 Answers
4

du reports free space by scanning reachable inodes and calculating their size.



If a file is created, opened, and later deleted while it is still open, the program that opened it will continue to have access to the file, and writes and reads can be performed to that memory location on disk. du does not account for such open files whereas df does.



A simple restart should flush /tmp and solve your problem.



An alternative would be to scan open files and restart or kill the process that did not release the deleted files.


[#34578] Saturday, November 26, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ippalogu

Total Points: 215
Total Questions: 127
Total Answers: 146

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;