civicrm_job_log is the biggest table in my database by an order of magnitude. And civicrm_log is the fifth biggest.

Can I trim these somehow, e.g. a cron job that removes old logs? It's making the backups slow.

EDIT: Here's an extension that keeps the job log from bloating

Thanks to the input here, I've created the Log Lop extension that allows users to configure a maximum age for keeping job logs. Will submit to the extensions directory after a bit more testing/few more eyes have looked at it.

  • 1
    In fact, that extension isn't necessary or a good idea either, just enable the core system job "Clean-up Temporary Data and File" [as noted when you click through to that extension].
    – Alan Dixon
    Commented Aug 24, 2020 at 17:42
  • Thanks @AlanDixon Commented Aug 25, 2020 at 18:18
  • Ah, but thank you for posting the original issue.
    – Alan Dixon
    Commented Aug 25, 2020 at 19:57

2 Answers 2


I think you can safely trim the civicrm_job_log, only the latest entries are probably useful (and given how little information the cronjobs return, I'd even doubt that ;)

As for the civicrm_log (or subscription history), it might be more risky to remove as you will loose "useful" history of what happened with your contacts, but from a technical point of view, it shouldn't be an issue, as long as you are ok losing that history.

  • Thanks, Xavier. Yeah I think I can live with not knowing that a record was changed some time in 2003, so I'll set up a cronjob to keep these tables trim. Many thanks. Commented Mar 8, 2016 at 13:16
  • 3
    Would be awesome if you would write an extension that provides a browser interface (using the api) for that trimming, ideally with a param to set the cut off date (eg delete everything that is older than "delta" days ago)
    – Xavier
    Commented Mar 8, 2016 at 13:18
  • What if said extension "archived" the "useful" history from civicrm_log to a separate table, or .sql file?
    – G H
    Commented Mar 8, 2016 at 19:53
  • Is it safe to trim civicrm_log? Since it stores a change history, by removing some of the first rows you might be removing original values?
    – John
    Commented Mar 9, 2016 at 9:28
  • the latest version is always stored into the "real" entity (eg. civicrm_contact). The log mostly doesn't contain any data per se, only meta data (bob changed the contact on the 1st of april last year)
    – Xavier
    Commented Mar 9, 2016 at 9:48

Truncate civicrm_job_log as often as you like - the data is only of very very marginal interest and only for a short period

I usually prefer to turn on DB logging - in which case the data in the civicrm_log table doesn't really add anything - it's only a little bit useful IMHO anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.