A single vhost on a cPanel server is writing 10 GB of access log a day. Logrotate runs nightly but the box runs out of inodes by 4 AM. The fix is not aggressive rotation — it is to stop writing the file at all on disk and instead pipe the log through a handler that ships it elsewhere or rotates in-stream. Apache’s piped log mechanism handles this; cPanel preserves the directive if you set it via the Include Editor.
What’s happening
CustomLog and ErrorLog can take either a filename or a pipe followed by a command. With a pipe, Apache forks the named program once at startup and writes log lines to its stdin. Standard handlers include rotatelogs (Apache’s own time-or-size-based rotator that compresses on the fly) and cronolog (older but still works). For a log-shipping setup, the pipe can be a vector or fluent-bit instance that forwards to a centralized log store.
How to verify
Confirm the current logging setup for the vhost:
apachectl -t -D DUMP_INCLUDES | grep -A3 example.com
grep -r "CustomLog\|ErrorLog\||" /etc/apache2/conf.d/userdata/std/2_4/<user>/<domain>/ 2>/dev/null
ls -la /usr/local/apache/domlogs/<user>/
which rotatelogs
If the vhost is using the default per-domain file, the include shows CustomLog "/usr/local/apache/domlogs/<user>/<domain>" combined.
The fix
- Confirm
rotatelogsis available:which rotatelogsshould return/usr/sbin/rotatelogson most cPanel builds. - WHM > Apache Configuration > Include Editor > Post VirtualHost Include > scope to the user’s vhost > add:
This writes to a daily-rotated file underCustomLog "|/usr/sbin/rotatelogs -L /var/log/apache2/example.com/current.log -p '/usr/local/cpanel/bin/post-rotate-compress.sh' /var/log/apache2/example.com/%Y/%m/%d/access.log 86400 -0" combined/var/log/apache2/example.com/YYYY/MM/DD/access.log, keeps acurrent.logsymlink, and runs a post-rotate hook to compress. - Pre-create the directory tree and
post-rotate-compress.sh:mkdir -p /var/log/apache2/example.com cat > /usr/local/cpanel/bin/post-rotate-compress.sh <<'EOF' #!/bin/bash zstd --rm "$1" & EOF chmod +x /usr/local/cpanel/bin/post-rotate-compress.sh apachectl -t && apachectl graceful. Confirm Apache forked therotatelogschild:ps -ef | grep rotatelogs.- Watch for an hour.
current.logshould be growing; the previous hour’s file should be compressed and renamed. If the symlink is not updating, the-Lflag is being misinterpreted — check Apache’s version. - AWStats integration: AWStats expects files in
/usr/local/apache/domlogs/. If you move to piped logs, either point AWStats at the new path via WHM > Statistics Software Configuration, or run a nightly cron that copies the compressed files back to the cPanel-expected location for AWStats.
For environments where one or two vhosts dominate the log volume, Stack Harbor sets piped logging on those vhosts only as part of cPanel server management.