越简单越好!

Freebsd Nginx 日志分割

发表于 2011-06-15 15:43 | 1374次阅读 0次点赞   Freebsd

#vi cut_log.sh

#!/bin/sh
logs_path="/data/log/nginx/"
date_dir=${logs_path}$(date -v "-1d" +"%Y%m")/$(date -v "-1d" +"%d")/
mkdir -p $date_dir
mv ${logs_path}access.log $date_dir
/usr/local/sbin/nginx -s reopen

#chmod +x cut_log.sh

加入到crontab 每天0点执行。

返回顶部 ^