if [ $# -eq 1 ]
then
echo "valid database"
db_name=$1
else
echo "please enter database"
fi
then
echo "valid database"
db_name=$1
else
echo "please enter database"
fi
function log()
{
caller="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")";
_log="$(date +"%y/%m/%d %h:%m:%s") info ${caller} (${function[1]}): $1";
echo="$_log" | tee -a /home/hive/recordcount.log;
}
if [! -f .process ]; then
echo "No previous running ingest process found";
else
previous_pid="`cat .process`";
is_running="`ps -ef | grep -w $previous_pid | grep -v grep | wc -1 `";
if [ $is_running -ge 1]; then
log " process still running with PID: $previous_pid";
exit -1;
fi
fi
echo $$>.process
hive -e "use $db_name;show tables;">hive-tables.txt
files="$(<hive-tables.txt)"
for tbl1 in $files;
do
recordcount1=`hive -e "select count(*) from $db_name.$tbl1;"`
#if [$recordcount1>0]
#then
echo "the table name: $tbl1: Record count:$recordcount1">>files.recordcount1.txt
#file1
done