Bash: Remove History Log

cd /logs

hisDate=`date -d"-1 week" +%Y%m%d`

for currentD in `find /logs/ -type d`

do

    logDir=`echo $currentD|cut -d"/" -f4`

    logDate=${logDir}

    if [ ${hisDate} -gt 0 -a ${logDate} -gt 0 ] 2>/dev/null ;then

        _intervalGap=$(( ($(date +%s -d"${hisDate}")-$(date +%s -d"${logDate}"))/86400 )) 

        if [ ${_intervalGap} -gt 0 ] ;then

            echo $currentD

        fi

    fi

done

猜你喜欢

转载自www.cnblogs.com/xinyueliu/p/12458391.html