Housekeeping

Development Status
Work In Progress
Active Installs
Maintainers
Herunterladen

Last updated: 2026-08-26

Works with CiviCRM 6.16 or higher.

System Tools (logs, monitoring, crons)

CiviCRM creates a lot of data that nothing ever cleans up. Log files are rotated but never
deleted, so the log directory grows until someone notices a single file measured in hundreds
of megabytes. civicrm_system_log records every incoming payment notification and keeps it
forever. The mailing event tables — one row per recipient, per open, per click — are usually
the largest tables on any site that sends email. None of it is removed by core.

Housekeeping adds a daily scheduled job that purges these on a retention you control, one
policy per task:

* Rotated log files, and the trigger SQL files CiviCRM writes when it cannot create triggers
itself. It will also rotate a live log file that has gone stale, which core only does on write.
* The system log, the contact change log, the mailing spool, orphaned queue items, mailing
event history, and Detailed Logging history.
* Everything core's "Clean-up Temporary Data and Files" job does — sessions, temporary tables,
the prevnext cache, expired cache entries, the job log and the upload directory. Housekeeping
delegates to the same core code, so it replaces that job rather than running alongside it.
The core job is disabled automatically once Housekeeping has run successfully, and restored
if you disable this extension.

Each task has its own retention, so rotated logs can be kept for three months while trigger SQL
goes after one. Manage them at Administer > System Settings > Housekeeping Tasks: enable or
disable each task, set how long it keeps things for, and see when it last ran and what it
removed. A status check tells you if an enabled task has quietly stopped running.

Tasks that destroy data you may still want are OFF by default and have to be enabled
deliberately: the contact change log, mailing statistics, and the Detailed Logging audit trail.
Deletes run in batches, so a large table cannot lock up the database.

This is also groundwork for the "CiviCRM Housekeeping / cleanup" proposal in dev/core#5347 —
each task declares its type, policy and retention, mirroring the fields proposed for a core
HouseKeeping entity.