#!/bin/bash############################################## #Author: Liuzhengwei-[email protected] #QQ: 1135960569# Last modified:2017-08-16 16:05#filename:nginx_logrotate.sh#description:######################################### # # # # #back_dir =/usr/local/nginx/logs/year= ' date ' +%y ' month= ' date ' +%m ' [-D $back _dir/$year] && mkdir $back _ dir/$year/$month | | Mkdir-p $back _dir/$year/$monthcp $back _dir/access.log $back _dir/$year/$monthcp $back _dir/error.log $back _dir/$year/ $MONTHCD $back _dir/$year/$monthgzip-C access.log > Access.log_ ' (Date ' +%f ') '. Gzgzip-c error.log > Error.log_ ' ( Date ' +%f ') '. Gzfind./-name "*.log" | Xargs rm-f> $back _dir/access.log> $back _dir/error.log
This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1967719
Nginx Log cutting shell by day