Aller au contenu principal
Imprimer

How to Empty Logs in CWP Pro to Reduce Disk Usage

Running out of disk space on a CWP (Control Web Panel) Pro server is a common nightmare for system administrators. Lets’s learn How to Empty Logs in CWP Pro to Reduce Disk Usage today. Often, the culprit isn’t your website files or databases, but massive, runaway log files that accumulate silently in the background. If your server is showing a “Disk Full” error or services are failing to start, clearing these logs is the first step to recovery.

In this technical guide, we will walk through the exact SSH commands to identify and safely empty logs in CWP Pro without breaking your server services.

Cet article résout également les problèmes suivants :

  • CWP Disk Usage 100%: Reclaims space when the root partition is full.

  • Large error_log files in public_html: Cleans up PHP error logs that grow to several gigabytes.

  • Apache domlogs taking too much space: Reduces the size of domain-specific access logs.

  • PHP-FPM log file too big: Fixes issues where php-fpm.log consumes disk overhead.

  • CWP Services not starting due to No Space Left: Frees up enough blocks for MySQL and Apache to initiate.

  • Slow server performance due to I/O wait: Reduces disk writes caused by constant logging of errors.

  • Daily Backup Failures: Solves “Insufficient Disk Space” errors during the CWP backup process.

  • High Inode Usage: While primarily for space, clearing logs helps in managing file system overhead.


Step 1: Check Current Disk Usage

Before you begin, you must verify the state of your partitions.

Initial Command: df -h

Le df -h command stands for “disk free” in a human-readable format. Execute this to see which partition (usually / ou /home) is at 100%.

df -h

Step 2: Identify and Empty User-Level Error Logs

CWP users often have error_log files generated within their public_html or home directories. These are created by PHP when scripts have bugs or compatibility issues.

Command 1: Find Large Error Logs

This command searches the /home directory for any file named error_log larger than 100MB.

find /home -name "error_log" -size +100M

Command 2: Empty All User Error Logs Instantly

Instead of deleting the files (which can sometimes cause issues with running processes), we “truncate” them. This keeps the file but resets its size to 0 bytes.

find /home -type f -name "error_log" -exec truncate -s 0 {} \;

Step 3: Clear System-Wide Apache and PHP Logs

System logs located in /usr et /opt can grow indefinitely if log rotation is misconfigured.

Command 3: Empty Apache Domain Logs

These logs track every hit to every website on your server. They are located in the domlogs folder.

truncate -s 0 /usr/local/apache/domlogs/*

Command 4: Clear PHP-FPM Service Logs

If you are using PHP 7.4 (or similar versions), the service log can become bloated with service start/stop notices.

truncate -s 0 /opt/alt/php-fpm74/usr/var/log/php-fpm.log

(Note: If you use other PHP versions, change php-fpm74 to your specific version, e.g., php-fpm81).

Command 5: Empty Global Apache Logs

This targets the main Apache error and access logs that aren’t specific to a single domain.

truncate -s 0 /usr/local/apache/logs/*

Step 4: Verify Reclaimed Space

Now that the “heavy lifting” is done, check your disk stats again to see the difference.

Final Command: df -h

df -h

You should now see a significant reduction in the Used% column, allowing your CWP Pro services to breathe again.


FAQs: Managing Logs in CWP Pro

Q1: Why use truncate instead of rm? A1: If you delete a log file with rm while Apache is still writing to it, the disk space often isn’t actually freed until Apache is restarted. truncate resets the file size to zero immediately without requiring a service restart.

Q2: Will emptying these logs delete my website data? A2: No. These commands only target .log et error_log files. Your images, databases, and website code remain untouched.

Q3: How often should I run these commands? A3: If your disk is frequently filling up, you should run these weekly. However, a better long-term solution is fixing the PHP errors mentioned in those logs.

Q4: Can I automate this? A4: Yes. You can add these truncate commands to a Cron Job within your CWP admin panel to run every Sunday.

Q5: Is there a way to limit log sizes automatically? A5: Yes, ensure logrotate is installed and configured on your Linux server. CWP usually handles this, but it may need manual adjustment for very high-traffic servers.

Q6: What if my disk is still full after running these? A6: You may have large backups or temp files. Check /home/backup ou /tmp and use the command du -sh /* to find other large folders.

Q7: Does clearing domlogs affect AWStats or Webalizer? A7: Yes, if you clear domlogs before the stats are processed for the day, those specific hours of traffic might not show up in your visitors’ report.

Q8: Why is my php-fpm.log growing so fast? A8: This usually indicates a “Slow Script” or a pool reaching its max_children limit. Check the log content before truncating to see the warning.

Q9: Do I need root access for this? A9: Yes. These commands require root privileges via SSH.

Q10: Is CWP Pro required, or does this work on the Free version? A10: These commands work on both CWP Free and CWP Pro as the file structures are identical.

Table des matières
Fermer
Obtenez 75% + 10% de réduction supplémentaire sur les plans d'hébergement web par myglobalHOST

Réduction supplémentaire de 10%

Code des coupons

EXTRA10

Applicable le

Rs 100 de réduction

Code des coupons

FLAT100

Applicable le

Comment en bénéficier : Choisissez simplement le plan d'hébergement qui vous convient le mieux et bénéficiez d'une remise supplémentaire sur toutes vos commandes.