ubuntu下使用logrotate做nginx日志定时自动切分

ubuntu下使用logrotate做nginx日志定时自动切分。
配置文件位置:/etc/logrotate.d/nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/var/log/nginx/*.log {
	weekly
	missingok
	rotate 52
	dateext
	compress
	delaycompress
	notifempty
	create 0640 www-data adm
	sharedscripts
	prerotate
		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
			run-parts /etc/logrotate.d/httpd-prerotate; \
		fi \
	endscript
	postrotate
		[ -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
	endscript
}