Shell备分访问日志文件
#!/bin/bash
#备分文件路径
path=/backup/$(date +%Y)/$(date +%m)
#路基不存在就创建
if ! [ -d $path ];then
mkdir $path -p
fi
#目标文件,%(date +F%)表示 年-月-日的时间格式
destFile=$path"/$(date +%F).access_log"
fromFile=/var/log/httpd/access.log
mv $fromFile $destFile
touch $fromFile
/etc/init.d/httpd reload &>/dev/null
logger - t "日志轮转" "$(date +F)成功"
浙公网安备 33010602011771号