Linux使用logrotate定时分割日志

1、分割nginx日志
vim /etc/logrotate.d/nginx
/var/log/nginx/*log {
create 0644 nginx nginx
rotate 10
missingok
notifempty
compress
sharedscripts
postrotate
/bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
endscript
}

2、php-fpm日志
vim /etc/logrotate.d/php-fpm
/var/log/php-fpm/*.log {
missingok
daily
rotate 60
compress
nodelaycompress
notifempty
create 644 php-fpm nobody
sharedscripts
postrotate
/bin/kill -SIGUSR1 `cat /run/php-fpm.pid 2>/dev/null` 2>/dev/null || true
endscript
}

猜你喜欢

转载自www.cnblogs.com/fwqblogs/p/11957239.html
今日推荐