Skip to content

Trash and ~/cache cleanup on cPanel home directories

How to safely clean up Trash, ~/cache, ~/.cache, and other accumulators in a cPanel home directory — the policy and the verification.

A cPanel home directory accumulates a small number of predictable “junk” directories: ~/.trash, ~/cache, ~/.cache, ~/tmp. Together they’re often 5-15% of the account’s disk usage. Cleaning them is safe in most cases, but “most” matters — knowing the exceptions is what separates a defensible policy from a customer ticket apologizing for deleting their work.

What’s happening

~/.trash is cPanel File Manager’s trash directory. ~/tmp is per-account temporary storage (PHP sessions, Apache uploads in progress). ~/cache and ~/.cache are application caches (sometimes Composer, sometimes a framework-specific cache, sometimes a user-created custom directory). The first two are reliably safe to clean; the last two require a glance to confirm they aren’t holding something important.

How to verify

du -sh /home/<user>/.trash /home/<user>/tmp /home/<user>/cache /home/<user>/.cache 2>/dev/null
find /home/<user>/.trash -type f -mtime +30 | wc -l
find /home/<user>/tmp -name 'sess_*' -mtime +1 | wc -l
ls /home/<user>/cache /home/<user>/.cache 2>/dev/null | head

The ls checks confirm what’s actually in the cache directories — sometimes a customer manually named a directory cache for their own purposes.

The fix

  1. ~/.trash: safely emptyable. find /home/<user>/.trash -type f -mtime +30 -delete for items older than 30 days, or rm -rf /home/<user>/.trash/* if the customer has acknowledged the cleanup.
  2. ~/tmp: clean PHP sessions older than 1 day (find /home/<user>/tmp -name 'sess_*' -mtime +1 -delete). Leave other files alone — Apache upload-in-progress files can be there.
  3. ~/cache and ~/.cache: inspect first. Composer’s cache (~/.cache/composer) and npm’s cache (~/.npm) are safe to remove. Custom directories named cache are risky — coordinate.
  4. After cleanup, refresh the cPanel quota: /usr/local/cpanel/bin/quota_cache --user=<user> --rebuild. The customer’s account summary updates within minutes.
  5. Document the cleanup in the support note. If a customer asks “why is my disk usage 200 MB less than yesterday”, the answer should be a one-line ticket reference, not a guess.

Stack Harbor includes home directory cleanup in routine operations under managed cPanel operations.