bin/purge-audit-log.php deletes audit entries older than the retention period. It bootstraps Omeka S itself and needs no web server or job queue, which makes it suitable for cron. See Purging Old Entries for scheduling examples.
Usage
php /path/to/omeka-s/modules/AuditTrail/bin/purge-audit-log.php [--days N] [--dry-run] [--quiet]
The script locates the Omeka S root relative to its own path (three directories up), so it must stay inside modules/AuditTrail/bin/. Run it as a user that can read config/database.ini.
Options
| Option | Description |
|---|---|
--days N |
Use N days as the retention period instead of the module setting. Must be a positive integer. Also runs the purge when the module is disabled. |
--dry-run |
Print how many rows would be deleted and exit without deleting. |
--quiet |
Suppress normal output. Errors are still written to standard error. |
--help |
Print usage information and exit. |
Behaviour
- Reads the retention period from
--daysor the Retention period setting. - If the period is
0, prints Retention disabled and exits successfully. - If the module is disabled and
--dayswas not given, prints Module disabled; skipping purge and exits successfully. - Computes the cutoff (now minus the retention period) and deletes rows with an older timestamp in batches of 1,000 until none remain.
- Prints the number of rows deleted.
Example output:
[AuditTrail] Purging entries older than 2025-09-22 02:00:00 (365 days).
[AuditTrail] Purge complete: 1284 row(s) deleted.
Dry run:
[AuditTrail] [DRY RUN] Purging entries older than 2025-09-22 02:00:00 (365 days).
[AuditTrail] Dry run: 1284 row(s) would be deleted.
Exit codes
| Code | Meaning |
|---|---|
0 |
Success, or nothing to do |
1 |
Omeka S bootstrap or application config could not be found |
2 |
Invalid arguments (for example --days 0) |
Cron sends mail only when a job produces output, so --quiet combined with a non-zero exit code on error is the usual way to be notified of problems only.
Background job
The same purge is available as the Omeka S job AuditTrail\Job\PurgeAuditLog, which the Run purge now button on the log page dispatches. It reads the retention setting, deletes in batches of 1,000 and honours the job's stop request. Its log lines go to the Omeka S application log. There is no --days equivalent for the job.