缩小日志大小和备份文件用
如果想测试配置文件
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
下面是nginx php和mysql的日志设置
/var/log/nginx/*.log {
daily
size 1G
missingok
rotate 10
compress
delaycompress
notifempty
create 0640 nobody nobody
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then
run-parts /etc/logrotate.d/httpd-prerotate;
fi
endscript
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
/usr/local/php/var/log/php-fpm.log /usr/local/php/var/log/php-fpm.log.slow {
dateext
create
#maxage 90
rotate 60
missingok
sharedscripts
postrotate
/bin/kill -USR1 `cat /var/run/php-fpm.pid`
endscript
}
/var/lib/mysql/slow-log /var/lib/mysql/localhost.err {
dateext
create
# notifempty
#maxage 90
rotate 60
missingok
sharedscripts
postrotate
/usr/local/mysql/bin/mysqladmin -uroot -p'password' flush-logs
endscript
}