4

I've read various articles about reducing the size of civicrm_job_log, but couldn't come to a conclusion.

In This post :

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

Question 1) How to clean civicrm_job_log table ?

1.1) empty completly the table with this SQL query ?

TRUNCATE TABLE civicrm_job_log;

1.2) what if we want to keep the last 7 days of logs in that table ? Would this work ?

DELETE FROM civicrm_job_log WHERE run_time >= NOW() - interval 7 day;  

Problem : the date field is empty when looking at civicrm scheduled tasks log, so I'm afraid run_time is also empty in the table :( (will ask my DB admin to check)

As a workaround, this post explains how to keep the last 1000 entries.

I also read this, but find it strange to copy what we want to keep to a temporary table, then copy back to the original table. What do you think ?

Question 2) what is the impact (if any) of emptying completely the table ? If not impact at all, what is the purpose of this table ? If it's for troubleshooting, shouldn't there be a way to disable those logs when there's no problem requiring troubleshooting?

Question 3) I read that the scheduled task "Clean-up Temporary Data and Files" / cleanup removes old entries in civicrm_job_log. How many days are kept ? I think I read 30 days somewhere, is this true? Would be nice to be able to configure the retention period using a parameter in the task for example

1
  • I don't think anything actually removes old jobs without the last 1000 entry post. I run that manually every weekend (saving last 5000). Looking at the docs of that cleanup task, the default is for it to clean up jobLog cache, which may or may not refer to the civicrm_job_log table. Should put this into a scheduled task or cron job eventually, but would rather have CiviCRM put a date field in there and fix it officially. Commented Oct 13, 2022 at 0:25

0

Your Answer

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

Browse other questions tagged or ask your own question.