Skip to content

Commit

Permalink
Fix monthly date dmwm#104
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylogy committed Aug 23, 2022
1 parent e0ccb9c commit b793f1f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/cron4dbs_condor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ export HADOOP_CONF_DIR=/etc/hadoop/conf
year=`date +'%Y'`
month=`date +'%m'`
day=`date +'%d'`
i=2 # pre-last file this month

if [ $day -eq 01 ]; then
year=$(date -d 'yesterday' +'%Y')
month=$(date -d 'yesterday' +'%m')
day=$(date -d 'yesterday' +'%d')
i=1 # last file previous month
fi

hdir=hdfs:///project/monitoring/archive/condor/raw/metric
tmpDirs=`hadoop fs -ls ${hdir}/$year/$month | grep tmp$ | awk '{print $8}' | sed -e "s,\.tmp,,g" -e "s,${hdir},,g"`
pat=`echo $tmpDirs | tr ' ' '|'`
lastSnapshot=`hadoop fs -ls ${hdir}/$year/$month | egrep -v ${pat} | tail -1 | awk '{print $8}'`
lastSnapshot=`hadoop fs -ls $hdir/$year/$month | awk -F" " '{print $8}' | sort -nr | awk -v "var=$i" 'NR==var'`
#echo "Last available snapshot"
#echo $lastSnapshot
date=`echo $lastSnapshot | sed -e "s,${hdir},,g" -e "s,/,,g"`
Expand All @@ -41,6 +48,7 @@ if [ -z "${date}" ]; then
echo "No date to run" >> $log 2>&1
exit
fi

dotmp=`echo $date | grep tmp`
if [ -n "${dotmp}" ]; then
echo "Date ends with tmp" >> $log 2>&1
Expand Down

0 comments on commit b793f1f

Please sign in to comment.