问题标签 [du]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
94 浏览

linux - 释放的内存未反映在 DF 命令中

如 DF 命令所见,我的系统内存几乎已满

当我检查时,我看到一个目录消耗 7 GB。

我以“testuser”身份登录并通过“rm -rf 命令”释放了大部分内容,现在只剩下 200 MB 数据。

但是释放的内存并没有体现出来

但是 du 和 df 命令仍然不能反映释放的 6 .8 GB 内存。

我尝试重新启动系统,但没有任何好处。

这可能是什么原因?

0 投票
1 回答
33 浏览

unix - How to handle maxed out volume on EC2.

One of our servers has a directory, disk2, which is 95% full. However, when I run commands to determine where the majority of the space is being used, it shows it's int /disk2/backups - which is apparently mounted on a different filesystem on different, larger device, and which is only 31% full. Here's the output of the DU command for those two devices:

Having the /dev/xvdb at 95% makes me nervous, as it's a production server. I think it's been growing because I didn't notice it before. Cleaning up the backups has solved the issue before, but I think it's on a different device this time.

I'm having trouble figuring out where the major space usages is, partially because the backups keep showing up as the largest files when I run it metrics on /disk2. When I drill down into disk2 directories not in /backups, there doesn't seem to be anything huge.

Also, the heading put out by the du states "1 k blocks". Does this mean that the numbers should be multiplied by 1k? Does it apply to the used available column? I'm thinking it must mean bytes because the first volume is 50G and the second is 150G.

0 投票
2 回答
477 浏览

linux - 根据大小比较两个文件

我在提取不同大小的独特文件时遇到困难。

问题:在一个目录中存在几个文件,假设有 2 个 2 mb 的文件、4 个 4 mb 的文件和 3 个 6 mb 的文件。

现在,我们需要运行一个脚本来检查所有文件及其大小,并且只打印第一次出现的不同大小的文件。

例如。如果它读取一个文件 f1 并且它是一个 2mb 的文件,它将执行 ls -al of f1

下次如果它得到一个 2 mb 大小的文件,它将跳过它

因此在这种情况下,它将仅打印 3 个不同大小的文件,分别为 2 mb、4 mb 和 6 mb。

我正在脚本中尝试以下代码:

0 投票
2 回答
520 浏览

linux - 打印一种文件类型的“du”总数,目录不平坦

我有一个包含多种文件类型的目录,目录绝对不平坦,深度可变。 我想知道给定文件类型占用的卷大小。

我正在考虑在 du 之后过滤然后求和

它确实打印了一些东西,但总和肯定没有达到我的预期。我测试过

和值不加到目录大小:

我怎样才能做到这一点?

谢谢

0 投票
1 回答
109 浏览

bash - 计算文件夹大小排除文件硬链接

我正在使用带有 rsync 的 bash 脚本来创建每日和每周备份。简而言之,它是如何工作的:

  • 该脚本设置了几天和几周的变量。
  • 当天文件夹被清空:rm -rf /path/to/$currentday/*
  • 前一天的内容被复制到当天(硬链接):cp -ral /path/to/$previousday/* /path/to/$currentday/
  • 然后脚本同步所做的更改:rsync -tru --progress /path/to/SOURCE/* /path/to/$currentday/

这是通过 WAN 从一个存储设备拉到另一个。由于公司正在发展,我们需要监控每次脚本运行时实际通过 WAN 发送的数据量。

有没有办法让我计算$currentday文件夹并排除未更改的文件(仍然是硬链接)?

或者可能在脚本中添加一行来记录正在发送的文件?

我一直在搜索互联网,但不幸的是没有找到任何有用的东西,我尝试的所有内容都是文件夹的总大小,即 2TB。

有没有人愿意和我分享这个?

0 投票
1 回答
2141 浏览

linux - 以纯兆字节显示 DU 结果

我正在使用DU函数将目录大小输出到文件中,然后将其移动到 excel 文件中以添加总数。是否可以仅以 MB 为单位输出目录的大小(即使大小以 KB 或 GB 为单位):

例如,如果文件大小为 50kb,则输出将显示 0.048MB

但是我知道,du -h如果大小大于 1024,我无法保持 MB 为单位的大小,因为它会切换到 1G。但是du -m,值旁边没有显示 M(兆字节),因此对人类并不友好。

在此先感谢,

0 投票
2 回答
1996 浏览

du - 使用 BASH,如何使用“du -ch”仅输出总集合大小?

我试图du -ch在多个目录上运行,但我只分开它只显示所有文件的总大小(我不想要每个单独的文件,然后是最后的总数-c)。

0 投票
1 回答
1589 浏览

python - File size discrepancy between du command and Python function

I have a script I run nightly to get the ammt of stuff stored in a specific directory on my server. This is the function I am using for that core part:

For some reason, I am getting a different value when I manually run

With the Python I get 20551043874445 bytes (converts to 20.5 TB). With du I get 28 TB (I am re-running now without -h to get the value in bytes).

Clearly that Python function is missing something, but I'm not sure what or how. Any ideas?

0 投票
1 回答
66 浏览

linux - Bash 脚本 - 需要从目录中删除文件,直到目录大小小于 8 TB

下面是我需要为其创建 bash 脚本的高级场景。

  • 服务器上的目录- /sasdata2/SAS-USERS/PBU/
  • 上述目录的大小不应超过 8 TB
  • 如果大小超过 8 TB,则需要在“创建/修改”日期之前删除最旧的文件,以将大小恢复到 8 TB。
  • 此主目录中有几个子目录,但不应从子目录中删除任何内容。只能删除主目录中的文件。

下面是我正在使用的脚本,但它在 while 语句中进入无限循环。在为上述场景制作脚本时需要您的帮助。

0 投票
2 回答
83 浏览

shell - 使用 du 在目录树中查找文件类型?

我知道du *.txt例如给了我当前目录中的所有 .txt 文件,但是我可以以某种方式修改命令以不仅查看根目录而且查看其中的所有其他目录以查找所有 .txt 文件?