阿里云oss存储

一、统计大小

# 批量获取目录大小
paths="
oss://save_path/cdp_airflow-logs
oss://save_path/jvairflow-logs
"
for path in ${paths}
do
    statistic=$(ossutil du ${path} | grep 'total object count' ) # 统计路径
    count=$(echo ${statistic} |  grep -o '[0-9]\+' | head -n 1 ) # 获取对象个数
    size=$(echo ${statistic} |  grep -o '[0-9]\+' | tail -n 1 ) # 获取路径大小
    echo "${path}#${count}#${size}"
done


# 批量比对两天文件大小
dt_1=20230515
dt_2=20230522
paths="
oss://save_path/adm_pub_rpt_app_open_dur_dist_total_ds
oss://save_path/adm_log_app_open_install_list_ds
"
for path in ${paths}
do
    path_1=${path}/dt=${dt_1}/
    path_2=${path}/dt=${dt_2}/
    #echo ${path}
    size_1=$(ossutil du ${path_1} --block-size GB | grep 'total du' | awk -F ':' '{print $2}')
    size_2=$(ossutil du ${path_2} --block-size GB | grep 'total du' | awk -F ':' '{print $2}')
    echo "${size_1}#${size_2}"
    #echo ""
done


# 根据表名比对大小
# 设定参数
full_tb_name="ssjt.shy"
dt_1=20230516
dt_2=20230522
# 表路径
db=${full_tb_name%.*}
tb=${full_tb_name#*.}
tbl_path=oss://save_path/${db}/${tb}
# 统计大小
path_1=${tbl_path}/dt=${dt_1}
path_2=${tbl_path}/dt=${dt_2}
size_1=$(ossutil du ${path_1} --block-size GB | grep 'total du' | awk -F ':' '{print $2}')
size_2=$(ossutil du ${path_2} --block-size GB | grep 'total du' | awk -F ':' '{print $2}')
echo "${size_1}#${size_2}"

你可能感兴趣的:(阿里云,linux,经验分享)