清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/bin/bash # 00 00 * * * /bin/bash /usr/local/nginx/nginx-cutlog.sh # written: 51clocker # email : admin@51clocker.com # blog: http://www.51clocker.com nginx_log="/usr/local/nginx/logs/" logs_path="/data/nginxlog/" date_year=`date -d "yesterday" +"%Y"` date_mon=`date -d "yesterday" +"%m"` yesterday=`date -d "yesterday" +"%Y-%m-%d"` cutlog(){ mkdir -p ${logs_path}${date_year}/${date_mon} cd ${nginx_log} for i in `ls *.log` do filename=`echo ${i} | sed 's/\.log//'` mv ${nginx_log}$i ${logs_path}${date_year}/${date_mon}/${filename}.${yesterday}.log done kill -USR1 `cat /usr/local/nginx/logs/nginx.pid` } cutlog