On s'appuie sur le service logrotate. Créer un fichier de configuration /etc/logrotate.d/nextcloud
# Rotation des fichiers de logs de l'application web nextcloud
# Rotation quotidienne des journaux
# conservation des traces pendant 1 an
/srv/nextcloud/log/access.log
/srv/nextcloud/log/error.log
/srv/nextcloud/log/nextcloud.log
{
su www-data www-data
daily
rotate 365
nocompress
missingok
create 0660 www-data www-data
sharedscripts
postrotate
/usr/sbin/apache2ctl -k graceful
endscript
}
/srv/nextcloud/log/fpm-php-errors.log
{
su www-data www-data
daily
rotate 365
nocompress
missingok
create 0660 www-data www-data
postrotate
/usr/lib/php/php7.3-fpm-reopenlogs
endscript
}