切割Nginx日志

切割Nginx日志 这个是cp了 s135的 哈哈, 这个还是很有用的 ,把日志mv 到空间比较大的分区去,不用老担心磁盘满报警
[[email protected]_evan_vm logs]# cat /data/cut
#!/bin/bash
#The nginx logs path
logs_path="/usr/local/nginxbak/logs/"
oldlogs_path="/data/logs/"
mkdir -p ${oldlogs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log ${oldlogs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log

[[email protected]_evan_vm logs]# crontab -l
30 02 * * * /data/cut
结果如下
[[email protected]_evan_vm logs]# ls /data/logs/2013/02/access_20130227.log
/data/logs/2013/02/access_20130227.log