I have a ubuntu(don't know the version) server, in which I am trying to clear the following 4 sub-folders.


I know using the following 1-liner command I can clear all those folders, after I have cded to the magento-root/ folder, but somehow it doesn't work.

rm -rf var/{cache,session,report,log}/*

What could be reason for this, is there any setting through which this can be turned off ?

  • Did you use the command with sudo? – edwinksl Sep 30 '16 at 11:02
  • Command works for me where I have appropriate permissions. – Arronical Sep 30 '16 at 11:03
  • I don't have server sudo credentials, due to security risk, but I don't think sudo is required for using curly brackets for multiple folders whereas rm -rf var/cache/* works fine without need of sudo overrides. I can delete all those sub-folders separately, but if I run the 1-liner, it never works. – Vicky Dev Sep 30 '16 at 11:04
  • I didn't use -rf when I tested. Does it fail silently? – Arronical Sep 30 '16 at 11:08
  • And you're just trying to delete what's inside the subdirectory right? Not the subdirectory itself. – Arronical Sep 30 '16 at 11:09

As per your comment Is there any other 1-liner by which I can clear those folders regardless of they are empty or not ? use this:

other 1-liner

Use this:

First make sure you are in the magento-root/ directory. Then run this line:

$ for i in var/cache var/session var/log var/report; do rm -rf $i/* ;done

If you are not in the magento-root directory use use this one liner cd to the magento-root directory:

 cd magento-root; for i in var/cache var/session var/log var/report; do rm -rf $i/* ;done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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