Skip to content

Instantly share code, notes, and snippets.

@mactanxin
Created March 28, 2012 09:15
Show Gist options
  • Save mactanxin/2224981 to your computer and use it in GitHub Desktop.
Save mactanxin/2224981 to your computer and use it in GitHub Desktop.
#!/bin/sh
usage () {
echo "usage: $0" 1>&2
exit 2
}
if [ $# -lt 1 ] ; then
usage
fi
START_DATE=$1
END_DATE=$2
V_YEAR=$(echo $START_DATE | cut -c 1-4)
V_MONTH=$(echo $START_DATE| cut -c 5-6)
COUNTER=0
CURRENT_DATE="$START_DATE"
LOGFILE_PATH=/opt/_tmp
if [ ! -d "$LOGFILE_PATH" ]; then
mkdir -p $LOGFILE_PATH
fi
while [ "$CURRENT_DATE" \<= "$END_DATE" ];do
# for i in {25,32,33,34,36,37,71,72};
for i in {25,32};
do if [ ! -d "$LOGFILE_PATH/$CURRENT_DATE/$i" ]; then
mkdir -p $LOGFILE_PATH/"$CURRENT_DATE"/"$i"
fi
scp user@ip_address:/backup/v1/$i/access_log.$CURRENT_DATE.tar.gz $LOGFILE_PATH/$CURRENT_DATE/$i.tar.gz;
done;
gunzip -c $LOGFILE_PATH/$CURRENT_DATE/*.tar.gz | awk -f platform_carrier.awk > $LOGFILE_PATH/$CURRENT_DATE.txt
rm -rf $LOGFILE_PATH/$CURRENT_DATE/*
rm -rf $LOGFILE_PATH/$CURRENT_DATE/
COUNTER=$(($COUNTER+1))
CURRENT_DATE=$(date -d "${START_DATE} -d +${COUNTER} day" +%Y%m%d);
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment