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
- Global Logs: Targets the platform root logs (e.g.,
storage/logs/php-error.log). - Tenant Iteration: Loops through every subdirectory inside
/sites/. - Safe Truncation: For each site, if
application.logorphp-error.logexists, it applies the: > filenameBash operator. This empties the file instantly while keeping ownership and permissions fully intact.