#!/bin/bash
WORK_DIR=/home/pay/opbin/cut_log ts=$(date -d '1 hours ago' '+%Y%m%d%H');
for LOGFILE in `sort $WORK_DIR/{logfiles,logfiles_zhengli}|uniq |awk '{print $1}'` do LOG_DIR=`echo $LOGFILE | awk -F "//" '{ print $1 }'` LOG_FILE=`echo $LOGFILE | awk -F "//" '{ print $2 }'` if [ ! -f $LOG_DIR/$LOG_FILE ] then echo "Log file $LOGFILE isn't exist.\n" >> cut_log_error.log else if [[ ! -e $LOG_DIR/$LOG_FILE.$ts ]];then #cp $LOG_DIR/$LOG_FILE $LOG_DIR/$LOG_FILE.$ts; echo "" > $LOG_DIR/$LOG_FILE mv $LOG_DIR/$LOG_FILE $LOG_DIR/$LOG_FILE.$ts fi fi done