日志截取
#!/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