Skip to content
jagaweb.Book the Review
Hosting

Fixing Inode Limits: Cleaning Millions of Cache Files via SSH

4 min readBy JagaWeb Technical Team

Resolve 'No space left on device' (Inode limit) by finding and deleting millions of runaway PHP session files and stale cache files via SSH.

The Silent Killer: Inode Limits

You have 50GB of disk space free, but your cPanel says No space left on device. Your database crashes, and sessions fail to write.

You have hit your Inode Limit.

An inode represents a single file or directory. Shared hosts (like Exabytes or Hostinger) often cap accounts at 200,000 or 400,000 inodes. If a caching plugin or PHP session handler goes rogue, it can generate millions of tiny 1kb files, exhausting your inode quota instantly.

1. Finding the Inode Culprit

SSH into your account and run this command to count files in directories. This will take time if there are millions of files:

find . -maxdepth 1 -type d | while read -r dir; do printf "%s:	" "$dir"; find "$dir" -type f | wc -l; done | sort -n -k 2

Common culprits:

  • /home/username/tmp/cpanel_php_sessions/
  • /home/username/public_html/wp-content/cache/wp-rocket/
  • /home/username/mail/ (Unread spam)

2. Safely Deleting Millions of Files

If a directory contains 500,000 files, running rm -rf * will fail with the error Argument list too long.

You must use find to delete them sequentially or pipe them to xargs:

# Delete old PHP sessions
find /home/username/tmp/ -name "sess_*" -type f -mtime +2 -delete

# Delete WP Rocket Cache
find /home/username/public_html/wp-content/cache/ -type f -delete

Using -delete natively with find is the fastest and safest method.

3. Preventing Recurrence

  • Ensure your PHP configuration has a cron job to clean up stale sessions (usually handled by the OS, but sometimes broken in cPanel MultiPHP).
  • Configure your caching plugin to auto-purge cache based on lifespan, not just to grow indefinitely.

Tired of obscure server errors taking your business offline? We stabilize and monitor environments for clients like Trexon Energy so inode exhaustion is caught and resolved automatically before it impacts production.

Stop fighting the server. Secure JagaWeb's RM5,000 Ownership & Access Review to audit your limits, or offload the headaches entirely to our RM450/month Care Plan.

PROTECT YOUR ASSETS

Ready to verify who owns your website?

Replace uncertainty with a decision-ready ownership and access report. The fixed Ownership & Access Review is RM1,500 before SST and includes a 30-day action plan.

WhatsApp