Linux 在unix中查找目录的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13061742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 17:36:53  来源:igfitidea点击:

Find the size of directory in unix

linuxunix

提问by AKIWEB

Problem Statement:-

问题陈述:-

I am getting this below exception-

我收到以下异常-

org.apache.hadoop.hdfs.protocol.DSQuotaExceededException:
org.apache.hadoop.hdfs.protocol.DSQuotaExceededException: The DiskSpace 
quota of /tmp is exceeded: quota=659706976665600 diskspace consumed=614400.1g

So I just wanted to know how much is the size of /tmp directory currently and because of that I am getting this exception. How can I see the free space in /tmp?

所以我只想知道当前 /tmp 目录的大小是多少,因此我收到了这个异常。如何查看/tmp 中的可用空间?

Update:-

更新:-

bash-3.00$ df -h /tmp
Filesystem             size   used  avail capacity  Mounted on
rpool/tmp               10G   2.2G   7.8G    22%    /tmp

I am puzzled right now why I am getting that exception then as it clearly states above that I have space available.

我现在很困惑为什么我会得到那个例外,因为它上面清楚地指出我有可用空间。

采纳答案by favoretti

You can do (For SunOS)

你可以做(​​对于 SunOS)

# du -sh /tmp

To see how much it uses now, but that you already saw.

看看它现在使用了多少,但你已经看到了。

To see how much total, free and used space is on the partition where /tmpresides you can use:

要查看/tmp所在分区上的总空间、可用空间和已用空间,您可以使用:

# df -h /tmp

Note that filling up space is not the only thing that can prevent writing to filesystem.

请注意,填充空间并不是阻止写入文件系统的唯一因素。

Running out of inodes is another popular reason.

耗尽 inode 是另一个流行的原因。

You can check that with

你可以用

# df -i /tmp

回答by pkm

for a in ls; do du -ch ${a} | grep total ; echo ${a}; done

对于一个ls; do du -ch ${a} | grep 总; 回声 ${a}; 完毕

try this but it takes time if the size of dir is in GBs

试试这个,但如果 dir 的大小以 GB 为单位,则需要时间

回答by PANDURANG BHADANGE

Managing HDFS Space Quotas It's important to understand that in HDFS, there must be enough quota space to accommodate an entire block. If the user has, let's say, 200MB free in their allocated quota, they can't create a new file, regardless of the file size, if the HDFS block size happens to be 256MB. You can set the HDFS space quota for a user by executing the setSpace-Quota command. Here's the syntax:

管理 HDFS 空间配额 重要的是要了解在 HDFS 中,必须有足够的配额空间来容纳整个块。如果用户在分配的配额中有 200MB 可用空间,则无论文件大小如何,如果 HDFS 块大小恰好为 256MB,他们都无法创建新文件。您可以通过执行 setSpace-Quota 命令为用户设置 HDFS 空间配额。这是语法:

$ hdfs dfsadmin –setSpaceQuota <N> <dirname>...<dirname>

The space quota you set acts as the ceiling on the total size of all files in a directory. You can set the space quota in bytes (b), megabytes (m), gigabytes (g), terabytes (t) and even petabytes (by specifying p—yes, this is big data!). And here's an example that shows how to set a user's space quota to 60GB:

您设置的空间配额充当目录中所有文件总大小的上限。您可以以字节 (b)、兆字节 (m)、千兆字节 (g)、兆兆字节 (t) 甚至 PB 为单位设置空间配额(通过指定 p——是的,这是大数据!)。这是一个示例,展示了如何将用户的空间配额设置为 60GB:

$ hdfs dfsadmin -setSpaceQuota 60G /user/alapati

You can set quotas on multiple directories at a time, as shown here:

您可以一次在多个目录上设置配额,如下所示:

$ hdfs dfsadmin -setSpaceQuota 10g /user/alapati /test/alapati