Symptoms

The Logrotate service logs errors on Ubuntu servers with an error such as the one below:

HOSTNAME logrotate[]: error: error renaming /usr/local/cpanel/3rdparty/wp-toolkit/var/logs/sw-engine.error.log to /usr/local/cpanel/3rdparty/wp-toolkit/var/logs/sw-engine.error.log.1.gz: Read-only file system

This error states that the WP-Toolkit logs cannot be written to or moved as the system is "read only".

Description

This happens on Ubuntu servers where Logrotate is controlled by Systemd, on these servers the ProtectSystem systemd variable is enabled which prevents the service from accessing file paths within the /usr and /etc Directories. This then leads to the error above as the WP-Toolkit logs are located within the /usr path.

We've opened an internal case for our development team to investigate this further. For reference, the case number is EXTWPTOOLK-13990. Follow this article to receive an email notification when a solution is published in the product. 

 

Workaround

This can be worked around by adding a ReadWritePath variable to the LogRotate service. This can be done with the four commands below, This should be performed by the root user via SSH:

  1. touch /usr/lib/systemd/system/logrotate.service.d/overwrite.conf
  2. echo -e "[Service]\nReadWritePaths=/usr/local/cpanel/3rdparty/wp-toolkit/var/logs/" | tee -a /usr/lib/systemd/system/logrotate.service.d/overwrite.conf
  3. systemctl daemon-reload
  4. systemctl restart logrotate

 

Afterward, you can verify this is enabled by running the command below. This will list the loaded environment variables for the Logrotate service and specifically check for the modification added in step 2 above.

systemctl show logrotate | grep -i '^readwrite'

A successful return when this is enabled will look like the following:

root@u22:/lib/systemd/system/logrotate.service.d# systemctl show logrotate | grep -i '^readwrite'
ReadWritePaths=/usr/local/cpanel/3rdparty/wp-toolkit/var/logs