cPanel AWStats & Access Log Rotation: Preventing Disk Quota Exhaustion in Pakistan

Resolve unexpected disk quota exhaustion on cPanel servers in Pakistan. Prune bloated AWStats cache files, rotate Apache domlogs, and automate cpanellogd cleanup safely.

cPanel AWStats & Access Log Rotation: Preventing Disk Quota Exhaustion in Pakistan

One of the most frequent support tickets received by hosting providers and server administrators across Pakistan involves sudden disk quota exhaustion. Webmasters find their websites throwing 500 Internal Server Error, emails bouncing due to full mailboxes, and cPanel backup scripts failing midway.

Upon inspecting disk usage via cPanel > Disk Usage, administrators are often shocked to find that website media and databases occupy less than 20% of their quota—while hundreds of thousands of files and tens of gigabytes are locked inside /home/username/tmp/awstats/ and Apache log directories.

Without proper log rotation and automated housekeeping, cPanel’s statistics engine (cpanellogd) continually generates uncompressed historical database text files that never purge automatically.


Executive Takeaways for Server Administrators

  • The Culprit Behind Phantom Inode Consumption: AWStats stores daily visitor metrics in flat files named awstatsMMYYYY.yourdomain.com.txt inside ~/tmp/awstats/. On sites with 10+ years of operation, these consume millions of inodes.
  • Domlog Accumulation in /usr/local/apache/domlogs/: Raw Apache access logs can grow by gigabytes daily under high traffic if log archiving is misconfigured in WHM.
  • Safe Truncation Protocol: Never delete active log files using rm while Apache or cpanellogd is running, as open file descriptors continue to consume disk space until the daemon restarts. Use truncation operators (> file).
  • High-Capacity Enterprise Storage: For mission-critical portals handling massive log volumes and data warehouses, our enterprise-grade Dedicated Servers in Pakistan offer multi-terabyte NVMe Gen4 arrays with zero per-gigabyte quota penalties.

1. Identifying the Source of Disk & Inode Bloat

Before deleting any files, connect to your server via SSH as root and run a targeted diagnostic scan across the /home partition.

Check Overall Disk and Inode Usage

# Check storage volume utilization
df -h /home

# Check inode consumption (number of files)
df -i /home

Find Accounts Consuming the Highest tmp Space

# Scan all accounts for large tmp directories
du -sh /home/*/tmp | sort -hr | head -n 15

If an individual account shows 10GB to 50GB inside /tmp, inspect its internal breakdown:

du -sh /home/username/tmp/*

Typically, /home/username/tmp/awstats/ and /home/username/tmp/webalizer/ represent over 90% of the consumed storage.


2. Safely Pruning Bloated AWStats Historical Data

AWStats reads raw Apache access logs and updates flat text files in /home/username/tmp/awstats/.

Deleting these files does not damage your website or current traffic stats; it simply removes historical monthly breakdown graphs inside the cPanel AWStats viewer (which most modern businesses already monitor via Google Analytics or Plausible).

Delete AWStats Files Older Than 90 Days

To retain the last 3 months of cPanel statistics while reclaiming disk space and inodes:

# Dry run: view files older than 90 days
find /home/*/tmp/awstats/ -name "awstats*.txt" -mtime +90 -type f

# Execute deletion safely
find /home/*/tmp/awstats/ -name "awstats*.txt" -mtime +90 -type f -delete

Purge Webalizer & Analog Cache

If your users do not use the legacy Webalizer or Analog stats tools, you can wipe their historical caches completely:

rm -rf /home/*/tmp/webalizer/*
rm -rf /home/*/tmp/analog/*

3. Disabling Legacy Statistics Engines in WHM

Why allow server resources to continually parse logs for statistics tools that nobody views? In WHM, you can permanently disable Webalizer and Analog while keeping only AWStats (or disabling all if using modern external analytics):

  1. Log into WHM as root.
  2. Navigate to Server Configuration > Tweak Settings.
  3. Click on the Stats Programs tab.
  4. Adjust the following settings:
    • Analog Stats: Off
    • Awstats Stats: On (or Off if you rely exclusively on external analytics)
    • Webalizer Stats: Off
  5. Scroll down to Delete each domain’s access logs after statistics processing:
    • Set to On (This prevents raw domlogs from lingering in user directories).
  6. Click Save.

4. Managing Apache Domlogs (/etc/apache2/logs/domlogs/)

Apache access logs for every hosted domain are written in real-time to /etc/apache2/logs/domlogs/ (or /usr/local/apache/domlogs/). On active websites, a single domain can generate 5GB to 15GB of raw access logs weekly.

How to Truncate Active Domlogs Without Crashing Apache

If a log file is filling up the root partition, running rm filename will delete the directory entry, but Apache will keep the inode open, preventing the disk space from being freed.

Always truncate open logs using the shell redirection operator:

# Safe truncation of a specific domain log
> /etc/apache2/logs/domlogs/example.com

# Truncate SSL log
> /etc/apache2/logs/domlogs/example.com-ssl_log

Configure Automated Log Rotation in WHM

Navigate to WHM > Service Configuration > cPanel Log Rotation Configuration. Ensure the following services are ticked for automatic rotation:

  • cpanellogd
  • access_log
  • error_log
  • maillog
  • Set Rotation Size Threshold to 300MB.

5. Automated Weekly Disk Cleanup Bash Script

To prevent disk quotas from ever choking again, implement this automated maintenance script running via cron:

Create /root/scripts/cpanel_log_cleanup.sh:

#!/bin/bash
# ==============================================================
# Nextgen cPanel Log & Statistics Maintenance Script
# ==============================================================

LOG_FILE="/var/log/cpanel_cleanup.log"
echo "[$(date)] Starting cPanel Disk & Stats Cleanup..." >> $LOG_FILE

# 1. Clean AWStats files older than 90 days across all cPanel users
find /home/*/tmp/awstats/ -name "awstats*.txt" -mtime +90 -type f -delete 2>/dev/null
echo "[$(date)] Purged AWStats caches older than 90 days." >> $LOG_FILE

# 2. Clear out legacy Webalizer and Analog files
find /home/*/tmp/webalizer/ -type f -delete 2>/dev/null
find /home/*/tmp/analog/ -type f -delete 2>/dev/null

# 3. Clean orphaned cPanel session lockfiles
find /home/*/tmp/ -name "sess_*" -mtime +3 -type f -delete 2>/dev/null

# 4. Truncate domlogs larger than 500MB
for log in /etc/apache2/logs/domlogs/*; do
  if [ -f "$log" ]; then
    size=$(stat -c%s "$log")
    if [ "$size" -gt 524288000 ]; then # 500MB in bytes
      > "$log"
      echo "[$(date)] Truncated oversized log: $log ($size bytes)" >> $LOG_FILE
    fi
  fi
done

# 5. Fix cPanel disk quotas
/scripts/fixquotas --quiet

echo "[$(date)] Cleanup Completed Successfully." >> $LOG_FILE

Make the script executable and add it to root cron:

chmod +x /root/scripts/cpanel_log_cleanup.sh

# Add to crontab to run every Sunday at 3:00 AM
crontab -e

Add line:

0 3 * * 0 /root/scripts/cpanel_log_cleanup.sh >/dev/null 2>&1

Upgrade to Scalable Storage Architecture

Disk quota anxiety is often a symptom of outgrowing shared or basic reseller hosting environments. When managing high-volume client portfolios or enterprise portals, migrating to dedicated bare-metal infrastructure on Dedicated Servers guarantees unmetered disk throughput, multi-terabyte dedicated NVMe drives, and unrestricted server customization.

Eliminate cPanel Disk Quota Headaches Today

Upgrade to Nextgen's high-capacity bare-metal and cloud server infrastructure in Pakistan. Dedicated enterprise NVMe storage arrays, unlimited cPanel inode allowances, and automated round-the-clock server health monitoring.