cPanel rotates Apache logs nightly into /usr/local/apache/domlogs/<user>/<domain>.gz and the global error_log daily by logrotate. The defaults are tuned for an average shared host. On a busy server — single tenant pushing 50 GB of access log a day — the defaults are too slow: the previous day’s uncompressed log fills the disk before the rotation runs. Tweaking the rotation timing and compression is the difference between a clean inode count and an emergency disk cleanup at 3 AM.
What’s happening
Apache writes to error_log, access_log, and per-domain logs in /usr/local/apache/domlogs/. cPanel’s /etc/cpanel/logrotate.d/ config rotates these once a day. The intermediate uncompressed log file sits at full size for up to 24 hours before compression. On a 50 GB-of-logs-per-day account, that single uncompressed file alone is 50 GB. AWStats reads the rotated files to generate the customer-facing stats; aggressive deletion breaks the stats unless you keep at least a week of compressed data.
How to verify
See the current rotation state and disk pressure:
df -h /
df -h /var /usr/local/apache/logs
du -sh /usr/local/apache/domlogs/* | sort -h | tail
cat /etc/logrotate.d/httpd
cat /etc/cpanel/logrotate.d/cpanel-logs 2>/dev/null
The first three commands show where the pressure is. The last two show the current config.
The fix
- Drop a custom logrotate snippet at
/etc/logrotate.d/apache2-cpanel-custom:
Hourly + maxsize 1G means a log file never grows past 1 GB before being compressed./usr/local/apache/domlogs/*/*.log { hourly rotate 168 # 7 days of hourly = 168 maxsize 1G compress compresscmd /usr/bin/zstd compressext .zst missingok notifempty sharedscripts postrotate /usr/sbin/apachectl graceful > /dev/null 2>/dev/null || true endscript }zstdis significantly faster thangzipfor the compression step, which matters when you are rotating every hour. - Confirm
logrotateis on an hourly schedule: cPanel’s default cron is daily. Add/etc/cron.hourly/logrotate-apacherunning/usr/sbin/logrotate /etc/logrotate.d/apache2-cpanel-custom. - Validate:
logrotate -d /etc/logrotate.d/apache2-cpanel-customruns in debug mode without rotating. Confirm the matched files are what you expect. - AWStats compatibility: cPanel’s AWStats configuration reads from
/usr/local/apache/domlogs/. As long as you keep the previous day’s compressed files around, AWStats handles them transparently — it knows about.gzand (recent versions).zst. Keep at least 48 hours of rotated logs to give AWStats time to run. - Disable any other logrotate config that also rotates these files. Two configs writing to the same log path will duplicate or conflict.
- Monitor the rotation.
find /usr/local/apache/domlogs -name '*.log' -mtime +1should always be empty — any file older than a day is failed to rotate.
For environments where disk pressure on log volume is a recurring incident, Stack Harbor maintains hourly compressed rotation on busy hosts under WHM server management.