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  

posted @ 2019-06-12 09:30  zhouyuqiang  阅读(337)  评论(0编辑  收藏  举报