How to Configure cPanel Log Rotation Settings Print

  • cpanel, log rotation, server logs, log management, cpanellogd, log archiving, whm configuration, server maintenance
  • 0

cPanel log rotation automatically compresses and archives your server log files at the end of each month, helping you manage disk space while preserving important historical data. The cpanellogd daemon handles this process, storing compressed logs in the /usr/local/cpanel/logs/archive/ directory where you can review them later.

Understanding cPanel Log Rotation

Log rotation is a critical maintenance task that prevents log files from consuming excessive disk space on your server. When you enable log rotation for specific log files, the system automatically compresses them into single monthly archives. This process occurs automatically at the end of each month without requiring manual intervention.

The cpanellogd daemon manages this compression process, creating separate archive files for each log type you've selected. These compressed files contain all the log entries from the previous month, making it easy to search through historical data when troubleshooting issues or analyzing server activity.

Important considerations:

  • The system does not automatically delete compressed log files. You must manually remove old archives to free up disk space when they're no longer needed.
  • This feature specifically handles cPanel system logs. For Apache web server logs, you'll need to configure rotation separately through the Apache Configuration section.
  • All archived logs are stored in /usr/local/cpanel/logs/archive/ by default.

How to Configure Log Rotation Settings

Configuring which logs get rotated is straightforward. Access the cPanel Log Rotation Configuration interface in WHM by navigating to Home >> Service Configuration >> cPanel Log Rotation Configuration.

Follow these steps to enable log rotation:

  1. Review the list of available log files displayed in the interface.
  2. Select the checkboxes next to each log file you want to compress and archive monthly.
  3. Click the Save button to apply your configuration.

Your changes take effect immediately, and the selected logs will be rotated during the next scheduled rotation period at month's end.

Which Logs Should You Rotate?

The specific logs you choose to rotate depend on your server usage and troubleshooting needs. However, most server administrators rotate the following logs:

  • Access logs: Track all login attempts and access to your control panel.
  • Error logs: Record system errors and warnings that can help diagnose issues.
  • Bandwidth logs: Monitor data transfer for billing or capacity planning.
  • Security logs: Document security-related events and potential threats.

Consider your compliance requirements and storage capacity when deciding which logs to keep. Logs containing sensitive information may need to be retained for specific periods based on industry regulations.

Managing Archived Log Files

Once logs are rotated and compressed, they remain in the archive directory indefinitely. Regular maintenance is essential to prevent the archive folder from consuming excessive disk space.

To manage your archived logs:

  • Periodically review the /usr/local/cpanel/logs/archive/ directory to assess storage usage.
  • Delete archives older than your required retention period.
  • Consider moving very old archives to backup storage if you need long-term access but want to free up server space.
  • Document your log retention policy so all administrators follow consistent practices.

You can access the archive directory through SSH or your file manager to download or delete old compressed log files as needed.

Frequently Asked Questions

How often does cPanel rotate log files?

cPanel rotates logs once per month, automatically compressing and archiving them at the end of each month. This monthly schedule ensures logs remain manageable while preserving sufficient historical data for troubleshooting and analysis.

Can I manually trigger log rotation before the end of the month?

While log rotation typically runs on a monthly schedule, you can manually execute the cpanellogd daemon if you need to rotate logs immediately. However, for most use cases, allowing the automatic monthly rotation to proceed is the best practice to maintain consistent archives.

What happens if I disable log rotation for a file that was previously enabled?

If you disable log rotation for a specific log file, it will simply stop being compressed and archived at the end of future months. Previously archived files remain in the archive directory untouched. The log file will continue to grow unrotated until you either re-enable rotation or manually manage it.

Where can I find my rotated log files?

All rotated and compressed log files are stored in the /usr/local/cpanel/logs/archive/ directory on your server. Each compressed file is named according to the log type and the month it represents, making it easy to locate specific historical logs when needed.

If you need assistance configuring log rotation or have questions about managing your server logs, our support team at OBHost is available 24/7 to help. Contact us through https://www.obhost.net/contact or email support@obhost.org for expert guidance.


Was this answer helpful?

« Back