hadoop fs -du -s -h /data/IT/PRD/IT_BI_PRD_REF/TR_L_POST_ACCT_CHRG_ITEM_REL,参考这条命令,写一个shell脚本查出所有Hadoop目录下表的占用空间
时间: 2024-10-19 13:06:05 浏览: 37
在Linux环境下,你可以编写一个简单的Shell脚本来遍历Hadoop文件系统(HDFS)并统计指定目录及其子目录下的所有表占用的空间。这里是一个示例脚本:
```bash
#!/bin/bash
# 定义要搜索的起始目录
START_DIR="/data/IT/PRD/IT_BI_PRD_REF/TR_L_POST_ACCT_CHRG_ITEM_REL"
# 使用hadoop fs命令查找目录及其所有子目录下的总大小
# -du 显示磁盘使用情况
# -s 合并子目录的大小
# -h 以人类可读的格式显示容量(如Kb、Mb、Gb等)
# --skip-trailing-slash 防止路径结尾有"/"导致递归错误
SIZE=$(hadoop fs -du -s -h $START_DIR --skip-trailing-slash)
echo "Total size of all tables in the directory $START_DIR: $SIZE"
# 查找所有子目录并递归计算
find "$START_DIR" -type d -maxdepth 1 | while read -r dir; do
SUB_DIR_SIZE=$(hadoop fs -du -s -h "$dir" --skip-trailing-slash)
echo "Sub-directory $dir occupies: $SUB_DIR_SIZE"
done
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![tgz](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![tgz](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)