nginx日志分割配置
vim /usr/local/nginx/nginx.sh
#! /bin/bash
savepath_log='/home/nginx/logs'
nglogs='/usr/local/nginx/logs'
mkdir -p $savepath_log/$(date +%Y)/$(date +%m)
mv $nglogs/access.log $savepath_log/$(date +%Y)/$(date +%m)/access.$(date +%Y%m%d).log
mv $nglogs/error.log $savepath_log/$(date +%Y)/$(date +%m)/error.$(date +%Y%m%d).log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

加入linux的crontab进程,让此脚本每天凌晨1点执行:
crontab -e
* 1 * * * /usr/local/nginx/nginx.sh