Skip to content

Finding large file offenders — mail logs, error logs, stray uploads

How to find the single big files on a cPanel server that take 5 minutes to discover and 30 seconds to fix — mail logs, error logs, abandoned upload temp files.

Not every disk-pressure event is a distributed accumulation. Sometimes it’s one 60 GB file: an Exim mainlog that nobody rotates, a debug log left on after a one-off troubleshooting session, an .iso a customer uploaded “to test something” and then forgot about.

What’s happening

A single oversized file is usually the result of misconfigured rotation, abandoned debugging, or a feature that grew without bounds. On cPanel, the common offenders are /var/log/exim_mainlog, /var/log/maillog, customer-side error logs in /home/<user>/public_html/error_log, and PHP-FPM slowlogs.

How to verify

find / -xdev -type f -size +500M 2>/dev/null
find /var/log -type f -size +1G 2>/dev/null
ls -lh /home/*/public_html/error_log 2>/dev/null | sort -k5 -h | tail
lsof | awk '{print $7, $9}' | sort -rn | head

lsof catches files still held open by a daemon — a deleted file held by Exim or MySQL shows up here and won’t be freed until the process closes the handle.

The fix

  1. Truncate, don’t delete, files held open by daemons: : > /var/log/exim_mainlog clears the content without invalidating the open file handle. rm followed by the file recreating would lose log lines until rotation.
  2. Rotate properly. Check /etc/logrotate.d/ — there should be entries for exim, cpanel, and each major application. Missing entries are how files reach 60 GB.
  3. PHP error logs in /home/<user>/public_html/error_log accumulate per-account and rarely rotate. Truncate them (: > error_log) after archiving any recent entries the customer might need.
  4. PHP-FPM slowlogs are useful for diagnosis but should not be left enabled. After troubleshooting, set slowlog_timeout = 0 in the pool config.
  5. Stray archives in /home/<user>: find /home/<user> -name '*.tar.gz' -size +500M. Customer uploaded an archive for migration and never deleted it — ask before removing, but most are forgotten.

Stack Harbor maintains log rotation and disk hygiene under cPanel server administration.