Logrotate is a Linux utility that manages log files created by system processes. It rotates, compresses, and removes logs according to the rules and policies written in configuration files.

If the Logrotate service on your server isn’t working, follow the steps below to troubleshoot the issue.

  1. Log in to your server via SSH; refer to our guide on connecting via SSH to learn how to do this. Note that you will need superuser permissions to edit the files, so you’ll need to log-in as the root user or create a new system user on RunCloud.
  2. After logging in, you can check whether the service is already running by executing the following command:
systemctl status logrotate.service
Failed to start Rotate log files.

The above screenshot shows that the logrotate.service failed with result ‘exit-code’.

  1. We can fix this by editing the configuration file and removing the duplicate occurrence of /var/log/nginx-rc/error.log. You either can do this manually via a text editor such as nano, or you can execute the following command in your terminal to do this automatically. If you don’t get any output then it means your command executed without any errors.
sed -i 's/\/var\/log\/nginx\-rc\/error\.log //' /etc/logrotate.d/nginx-rc
  1. Finally, restart the service and check its status by executing the following commands:
systemctl start logrotate
systemctl status logrotate.service
Logrotate service deactivated successfully.

In the above screenshot, we can see that the service terminated correctly, and shows the status as inactive rather than failed.