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
Get the files at Github: https://github.com/45squared/remove-transients-wordpress
We need to modify a few files in order for this to work in your environment.
- Modify the specified options on line 6
- Modify the table in line 9 if needed
- Save and close
- 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
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!