hive 异常任务中间数据清理

hive在运行过程中,会发现 hdfs /tmp/hive/hive or hdfs 目录占用空间巨大!

hive在运行过程中会生产大量的中间会话在/tmp目录下,

如果hive正常运行结束,临时会话会被自动清理掉,

如果hive中断,或者异常退出,这些中间会话就会一直保存在hdfs上。必须手动清理掉!

#!/bin/bash

usage="Usage: cleanup.sh [days]"

if [ ! "$1" ]

then

echo $usage

exit 1

fi

now=$(date +%s)

hadoop fs -ls /tmp/hive/hdfs | grep "^d" | while read f; do

dir_date=echo $f | awk '{print $6}'

difference=(( ( now - ( d a t e − d " (date -d " (date−d"dir_date" +%s) ) / (24 * 60 * 60 ) ))

if [ difference -gt 1 ]; then

echo $f

hadoop fs -rm -r -skipTrash echo $f| awk '{ print $8 }';

fi

done

相关推荐
鹿衔`1 天前
Hadoop HDFS 核心机制与设计理念浅析文档
大数据·hadoop·hdfs
`林中水滴`1 天前
数仓系列:一文读懂仓湖一体架构
数据仓库
Justice Young1 天前
Sqoop复习笔记
hadoop·笔记·sqoop
大厂技术总监下海1 天前
从Hadoop MapReduce到Apache Spark:一场由“磁盘”到“内存”的速度与范式革命
大数据·hadoop·spark·开源
zgl_200537791 天前
ZGLanguage 解析SQL数据血缘 之 Python提取SQL表级血缘树信息
大数据·数据库·数据仓库·hive·hadoop·python·sql
Justice Young2 天前
Hive第四章:HIVE Operators and Functions
大数据·数据仓库·hive·hadoop
LF3_2 天前
hive,Relative path in absolute URI: ${system:user.name%7D 解决
数据仓库·hive·hadoop
德彪稳坐倒骑驴2 天前
Hive SQL常遗忘的命令
hive·hadoop·sql
Justice Young2 天前
Hive第六章:Hive Optimization and Miscellaneous
数据仓库·hive·hadoop
Justice Young2 天前
Hive第五章:Integeration with HBase
大数据·数据仓库·hive·hbase