Export Purge
This guide explains how to automatically clean up old export files from your storage disk.
Overview
Export files (XLSX, CSV) can accumulate over time and consume storage space. The export package includes a purge command that removes files older than the configured number of days.
Configuration
Configure the purge behavior in config/datatables-export.php:
'purge' => [ // Remove export files older than this many days 'days' => 1,],
Manual Purge
Run the purge command manually whenever needed:
php artisan datatables:purge-export
Options
--days: Override the configured days value for this run
# Purge files older than 7 daysphp artisan datatables:purge-export --days=7
Automated Purge (Recommended)
Schedule the purge command to run automatically in routes/console.php:
use Illuminate\Console\Scheduling\Schedule; $schedule->command('datatables:purge-export')->daily();
How It Works
The purge command:
- Reads the configured disk from
config('datatables-export.disk') - Scans all files on the disk
- Identifies files with
.xlsxor.csvextensions - Deletes files modified before the configured cutoff date
- Outputs progress information
Important Notes
- The purge only affects export files (
.xlsx,.csv) - Files from other applications on the same disk are not affected
- The purge respects the configured storage disk, not the S3 disk
- Running the command multiple times is safe (idempotent)
Related Documentation
- Installation - Initial setup
- Export Usage - How exports work