Logrotate service fails with multiple php versions installed on Ubuntu Linux 20.04

I got this logrotate error on Ubuntu:

php7.4-fpm:1 duplicate log entry for /var/log/php-fpm/php-fpm.log
or
php7.4-fpm:1 duplicate log entry for /var/log/php-fpm/*.log


Tried to commented out

access.log = /var/log/php-fpm/php-fpm.log in /etc/php/7.4/fpm/pool/www.conf

That should disable logs from php-fpm7.4 but it did not work.

These files must be corrected as following:

/etc/logrotate.d/php7.2-fpm

/etc/logrotate.d/php7.4-fpm


for instance they both look the same:
 
/var/log/php-fpm/*.log {
weekly rotate 
10 missingok 
compress 
delaycompress 
notifempty 
sharedscripts
 
postrotate 
/bin/kill -SIGUSR1 `cat /run/php/php-fpm.pid 2>/dev/null` 2>/dev/null || true
 endscript 
}
Corrected versions file 7.2
/var/log/php-fpm/php7.2-fpm.log {
weekly
rotate 10
missingok
compress
delaycompress
notifempty
sharedscripts

postrotate
/bin/kill -SIGUSR1 `cat /run/php/php-fpm.pid 2>/dev/null` 2>/dev/null || true
endscript
}
file 7.4
/var/log/php-fpm/php7.4-fpm.log {
weekly
rotate 10
missingok
compress
delaycompress
notifempty
sharedscripts

postrotate
/bin/kill -SIGUSR1 `cat /run/php/php-fpm.pid 2>/dev/null` 2>/dev/null || true
endscript
}

Views: 17

Leave a Reply

Your email address will not be published. Required fields are marked *