45Squared

Removing Transient Database Entries

We’ve talked before about transients in your database and what problems they can cause. I spent some time writing a simple Python script to help manage these and also a script to create a log file for review.

Use the following at your own risk. 45Squared takes no responsibility for any unwanted results from this script.

Remove Transients for WordPress

We need to modify a few files in order for this to work in your environment.

File: transient.py

  1. Modify the specified options on line 6
  2. Modify the table in line 9 if needed
  3. Save and close

File transientarchive.py

  1. Modify line 3 to whatever directory you want to store logs into.

Once all the files are modified we can run the script. Please take a backup before you run this script as there is no undo option!

$ python transient.py

This will run the script. It will generate the log file called transient_delete_log.log

The log file is so you can verify that the script is actually deleting things. If a 0 is present then the script did not find anything to delete or you have a misconfiguration in your transient.py file.

I highly suggest setting this up to run on a CRON job. If you need help setting this up feel free to contact 45Squared at anytime!

Share This Guide, Choose Your Platform!

Connect with 45Squared

Exit mobile version