Cleaning up Magento installation: Which files & folders can be deleted?

You can safely delete the files in the following folders:

  • /media/import
  • /var/report

Besides of that you can also remove old session files by using find /path/to/magento/var/session -name 'sess_*' -type f -mtime +7 -exec rm {} \;

Removing old session files can already have a performance impact.

For improving the performance of you Magento installation there is even more you can do than just deleting old and unnecessary files.

34 ways to speed up your Magento e-commerce website


While it's ok to remove /www/media/catalog/product/cache it's where Magento stores resized images and doing it on a live site will cause a slowdown while Magento recreates all those cached images so it doesn't have to recreate them 'on the fly' whenever it needs to serve them out.

It's better to expire out cached images older than X days as removing product doesn't remove images.

Command line to clear out any cached images older than 6 months:

find /path/to/magento/media/catalog/product/cache/* -type f -mtime +180 -exec rm -f {} \;

Another cleaning technique is to download the Image Clean module from Magento Connect. Magento doesn't remove gallery images when product is deleted so you can have a horrific amount of junk images left if you have a lot of items you sell with a short product selling lifetime.

Also, make sure you have cron jobs set up properly as part of your disk space can be eaten up in storage of log_ tables in the database and if the log cleaning isn't functioning, the database grows immensely.


In addition to @mhauri's answer I'd like to add:

Check your var/log directory if the system.log or exception.log files are big. You should have a look at the issues in there before you empty the files.