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)成功"

posted on 2023-11-27 15:53  JPGer  阅读(7)  评论(0)    收藏  举报

导航