nginx自动切割日志脚本
#!/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
所有的问题都是最后一刻解决,如果没有解决,说明你还没有到最后