9

I want to make some space on disk and clean

What file & folders are safe to delete?

I found /media/import/ files are safe to delete

Deleting files and folder effect performance too?

Is it okay to delete '/www/media/catalog/product/cache'?

0

4 Answers 4

11

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

8

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.

1
  • I would add cleaning media/import folder and rm -rf /path/to/magento/var/import_history/*.csv
    – Gediminas
    Nov 2, 2018 at 11:13
3

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.

2
  • Thanks for edit and answer! I'm curious beside var folder, especially on media folder. My 'media' folder currently 32 GB :( which make some problem to me. (Yeah I have upload many products images but hope I can reduce some like I found I can delete /media/import/)
    – Yohan
    Feb 21, 2015 at 17:01
  • This one really clear good amount of space. Thanks @anna
    – Jarnail S
    Jan 24, 2017 at 7:05
-1

Cache and Sessions accumulate. Sometimes so much they can't be deleted from "within" the folder. Deleting the whole folder works but new folders must be put back into place and critical to duplicate original ownership and permissions so check before deleting

from within /magento/var/ directory rm -rf session rm -rf cache

3
  • var/session rm is a very BAD idea. You lose all customers Shopping Cart immediately. Also all customers will be logged-out. And admin users too. NEVER rm var/session/dir, ever. Feb 28, 2019 at 20:33
  • If you don't have any shopping cart data nor active users but you need access to the back end of your system.
    – L Arnold
    Dec 19, 2019 at 16:12
  • Got timed out so the comment full is here: If you don't have any shopping cart data nor active users but you need access to the back end of your system. It is best often good to first check on the status of your magento/var/bruteforce.ini file, as well as being sure your system maintenance (magento/maintenance.flag) file is not raised (rename it to maintenance.old if you need to). I agree that losing shopping carts is a problem but session and cache bloat in 1.x Magento has been an ongoing issue and this does work when I can't get access other ways.
    – L Arnold
    Dec 19, 2019 at 16:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.