menu_book Navigation menu

Log Management (clear_logs.sh)

Overview

Over time, PHP error logs and CMS application logs can grow large. Deleting log files directly (rm application.log) is a bad practice because active PHP-FPM workers hold file descriptors open; deleting the file can break logging until the service is restarted.

The clear_logs.sh script safely truncates log files to 0 bytes without destroying the file descriptor.

Execution

BASH
sudo bash /var/www/pragma-cms/scripts/cli/clear_logs.sh

How It Works

  1. Global Logs: Targets the platform root logs (e.g., storage/logs/php-error.log).
  2. Tenant Iteration: Loops through every subdirectory inside /sites/.
  3. Safe Truncation: For each site, if application.log or php-error.log exists, it applies the : > filename Bash operator. This empties the file instantly while keeping ownership and permissions fully intact.