Log Rotation on cPanel Servers

  WHM

Introduction

Log rotation is an essential maintenance task on hosting servers that helps manage log file sizes and prevents logs from consuming excessive disk space. On cPanel servers, log rotation is handled by different services depending on the type of log being managed.

This guide explains how log rotation works on cPanel servers and where the relevant configurations can be found.


Prerequisites

  • Root access to the server
  • Access to WHM
  • Basic knowledge of Linux log management

Implementation

cpanellogd Managed Log Rotation

Some cPanel-specific logs are rotated by the cpanellogd daemon.

The logs located under the following directory are managed by cpanellogd:

/usr/local/cpanel/logs

You can enable or disable log rotation for these logs through WHM:

Home → Service Configuration → cPanel Log Rotation Configuration


cPanel-Specific logrotate Configurations

Some cPanel-related services, such as PHP-FPM and suPHP, use the Linux logrotate utility for log rotation.

The configuration files for these services are maintained by cPanel and are located in:

/etc/logrotate.d/

These configurations are automatically managed by cPanel and generally do not require manual modification.


Custom Log Rotation

If new or custom logs are created on the server, they will require their own logrotate configuration.

Creating and maintaining custom log rotation configurations is typically a system administration task and may require assistance from a qualified administrator.


All Other Log Rotation

The logrotate utility manages all other logs on the server.

Their configurations can be found in either:

/etc/logrotate.conf

or

/etc/logrotate.d/


Viewing the logrotate Manual

If you need to create a new log rotation configuration for a custom log file, you can review the logrotate documentation using:

man logrotate


Creating a Custom Configuration

One of the easiest ways to create a custom log rotation configuration is to copy an existing configuration file and modify it to match the path and requirements of the new log file.


Scheduled Log Rotation

The logrotate utility uses anacron to schedule log rotations.

Configured log rotation jobs are executed through:

/etc/cron.daily/logrotate

The next scheduled run will process any newly added log rotation configurations.


Conclusion

Log rotation on cPanel servers is managed through both the cpanellogd daemon and the Linux logrotate utility. Understanding where these configurations are stored and how they operate helps ensure that log files remain manageable and do not consume excessive server resources.

LEAVE A COMMENT