Usage

Purging Old Entries

Entries are kept until they are older than the Retention period setting and a purge runs. Purges do not run on their own: start one from the log page or schedule the CLI script with cron.

Set the retention period under Admin > Modules > AuditTrail > Configure. The default is 365 days. A value of 0 means entries are kept forever and every purge exits without deleting anything. See Configuration.

Purging from the admin

Only global administrators see this option.

  1. Open Audit Trail in the admin sidebar and scroll to the Retention Purge section at the bottom of the page.
  2. Click Run purge now.

A background job is queued and the message Retention purge job has been queued is shown. The job deletes entries with a timestamp older than the retention period, in batches of 1,000 rows, and stops cleanly if it is asked to stop from Admin > Jobs. Its progress lines (cutoff date, rows deleted) are written to the Omeka S application log.

The job runs through Omeka's job dispatcher, so it needs a working PHP CLI path in the Omeka configuration (config/local.config.php, cli section). If jobs stay at Starting on your installation, use the CLI script instead.

Purging from the command line

The script modules/AuditTrail/bin/purge-audit-log.php bootstraps Omeka S and deletes old entries directly, without the job queue.

# Use the retention period from the module settings
php /var/www/omeka-s/modules/AuditTrail/bin/purge-audit-log.php

# Delete entries older than 90 days, ignoring the setting
php /var/www/omeka-s/modules/AuditTrail/bin/purge-audit-log.php --days 90

# Report how many rows would be deleted, without deleting
php /var/www/omeka-s/modules/AuditTrail/bin/purge-audit-log.php --dry-run

Run it as a user that can read config/database.ini. Options and exit codes are listed in CLI Script.

If the module is disabled in settings, the script does nothing unless --days is given.

Scheduling with cron

Run the purge nightly with --quiet so cron only sends mail when the script exits with an error:

# Purge Audit Trail entries nightly at 02:00
0 2 * * * /usr/bin/php /var/www/omeka-s/modules/AuditTrail/bin/purge-audit-log.php --quiet

Replace /usr/bin/php with the output of which php and the path with your Omeka S root. Test the command manually as the cron user before scheduling it. To keep a record of each run, drop --quiet and append the output to a log file:

0 2 * * * /usr/bin/php /var/www/omeka-s/modules/AuditTrail/bin/purge-audit-log.php >> /var/log/omeka-audit-purge.log 2>&1

If you run several Omeka S installations on one server, add one line per installation.

Log in for Support