Maintain and cleaning your old Magento Cache and Log records can greatly improve your Magento Database performance. Very often Magento database grows big in size due to large log tables and it might be a good idea to regularly perform a maintenance clean up.
To achieve this you can create a small script to be executed on regular bases. The exact script code can be found here.
The second option clean old logs and cache files as well as pearlib downloads and cache in the following directories:
To perform the any of the above tasks simply create a file called cleanup.php in your Magento home directory via FTP or your cPanel -> File Manager. You can copy the content of the file from this example.
When you have the file placed in your Magento folder with the copied contend you will need to access the file via:
http://www.domain.com/cleanup.php?clean=log --clean log tables http://www.domain.com/cleanup.php?clean=var --clean cache files
Remember to change "www.domain.com" with your actual domain name.
If you would like to have this executed on regular bases you may set a cron job via your cPanel -> CronJobs following our cPanel Tutorial on How to Setup a CronJob. The exact command should be:
curl -s -o /dev/null http://www.domain.com/cleanup.php?clean=log curl -s -o /dev/null http://www.domain.com/cleanup.php?clean=var