#!/bin/bash
savepath_log='/data/logs'
nglogs='/data/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
chown -R nginx:nginx $nglogs
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
定时任务:
* 00 * * * /usr/bin/bash /root/scripts/nginx-log.sh