-2
I need to check the used space in some folders, and I need it to be fast to check because it will be inside a script.
Which command should I use, "du -h" or "df -h"??
-2
I need to check the used space in some folders, and I need it to be fast to check because it will be inside a script.
Which command should I use, "du -h" or "df -h"??
3
Well, they don't do the same thing, so it's a fairly easy choice! df
reports file-system usage. du
reports usage for directories.
2
You want du
as it gives you the space used by specific files and/or folder(s). df
is used for checking the space used on entire filesystems.
1
Clearly the answer is du, as the prior respondents stated. If you want to specify the exact directories you're interested in and only want a summary for each then you would use:
du -hs /path/to/dir1
du -hs /path/to/dir2
etc
0
df
reports on file systems, du
measures directory contents.
Based on your requirements, use: du -h
Ok, but du still takes a lot of time to finish. Is there any way to check the space used in less time than du? – None – 2011-08-29T11:14:37.007
I don't think
du
can be sped up; it depends on the directory tree you're trying to check. Depending on what your actual requirements are, doing afind
for files larger than a specific size may be more appropriate? – Stuart McLaughlin – 2011-08-29T11:19:55.123I can't exclude files because I try to get the used space for a hosting, so it must include everything. So, in large hostings, it takes too long and the method returns an Internal Timeout. – None – 2011-08-29T11:52:19.273
If speed is really a need, make your directory a mount point for a separate file system. – Xenoactive – 2011-08-30T03:37:17.710