#!/bin/bash
path=`head -1 input1.txt`
dd=""
path2=""
#获取小时
aa=`echo $path | cut -d \/ -f 6`
#获取年月日
aa2=`echo $path | cut -d \/ -f 5`
cc=$((aa))
if [ $cc -lt 9 ]; then
bb=$((cc+1))
dd="0$bb"
path2="/data/dpi/test/$aa2/$dd"
echo $path2 > input2.txt
elif [ $cc -eq 9 ]; then
bb=$((cc+1))
dd="$bb"
path2="/data/dpi/test/$aa2/$dd"
echo $path2 > input2.txt
elif [ $cc -ge 10 ]&&[ $cc -lt 23 ]; then
bb=$((cc+1))
dd=$bb
path2="/data/dpi/test/$aa2/$dd"
echo $path2 > input2.txt
else
aa2=`date -d "$aa2 1 days" +"%Y%m%d"`
path2="/data/dpi/test/$aa2/00"
echo $path2 > input2.txt
fi
a=$(hadoop fs -count $path2 | awk '{print $2}')
if [ $a -gt 0 ]; then
spark-submit --class com.spark.DataClear --master yarn-client --executor-memory 8g --num-executors 8 --executor-cores 2 /home/haduser/study05-1.0-SNAPSHOT.jar $path /dataclear/$aa2/$aa
hadoop fs -mkdir -p /complete/$aa2/$aa
echo "/dataclear/$aa2/$aa" > "/home/haduser/timetest/$aa2.$aa.ok"
path3=`head -1 input2.txt`
echo $path3 > input1.txt
fi
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537832/viewspace-2745915/ ,如需转载,请注明出处,否则将追究法律责任。