我不是在寻找工具。我希望编写一个清晰的故障分析脚本,这样我就可以将其发送给不知道如何执行此操作的 VPS 用户。
我正在寻找一种通过 shell 脚本收集大量有关磁盘使用情况的数据的方法。在我的工作中,很多人打电话询问“为什么我的磁盘已满” 我运行 du -h --max-depth=1 | sort -rn 但这有点笨拙,我必须继续进一步挖掘......
我正在尝试通过这样的 shell 脚本来分割磁盘使用情况:
**home/ is consuming 400GB of disk space**</br>
home/user1 120GB
home/user2 200GB
**var/ is using 100GB of disk space**
到目前为止,我想出了以下内容:
#!/bin/bash
for i in $(ls -d */ | grep -v proc);
do
printf "**** $i has the following breakdown ********\n"
du -h --max-depth=1 $i
done
有什么方法可以为我的用户提供更清晰、更容易理解的磁盘使用情况分割?只是希望能够将用法包裹在漂亮的粉红色蝴蝶结中并说“祝你好运”
最佳答案
尝试一下ncdu (NCurses Disk Usage) ,例如:
$ ncdu -q -x
选项:
-q Quiet mode. While scanning or importing the directory, ncdu will
update the screen 10 times a second by default, this will be
decreased to once every 2 seconds in quiet mode. Use this
feature to save bandwidth over remote connections.
和
-x Do not cross filesystem boundaries, i.e. only count files and
directories on the same filesystem as the directory being
scanned.
关于linux - 客户端的可编写脚本的磁盘使用情况分割,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51492813/