日志截取

#!/bin/bash
cd /home/hm
echo "check dir "
dates_7=`date -d -7days '+%Y-%m-%d'`
if [ -d "$dates_7" ]; then
echo "del $dates_7"
rm -rf $dates_7
fi

currentdate=$(date '+%Y-%m-%d')

echo $currentdate

if [ ! -d "$currentdate" ]; then
mkdir $currentdate
mv /home/hm/*.log /home/hm/$currentdate

if [ $? -eq 0 ];then
echo "succeed"
else
echo "failed"

fi
fi

posted @ 2020-02-04 08:06  countryboy666  阅读(84)  评论(0编辑  收藏  举报