Forums / General Questions / How to purge bmz cache folders automatically?

How to purge bmz cache folders automatically?

Views: 2,971

Results 1 to 8 of 8
31 Dec 2012, 2:40 PM
#1
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

How to purge bmz cache folders automatically?

I use shared hosting and my host puts a limit on the number of files/folders per directory at 1024. If I go over am in violation of their Service Agreement and face possible suspension. The problem is that a plugin I use with my Zen Cart site caches files in a bunch of directories and due to the large number of product images/categories in my cart will eventually exceed 1024 files per directory unless I regularly clean out or delete the cache folders.

I would like to set something up that takes care of this for me automatically. Want to know if I can have all the files in particular folders automatically purged when the number of files per folder reaches 1000, and if so how would I go about it.

If that is not possible (or practical for a newbie to do on their own) would like to know how to set up something that will either delete all the files in each folder on a bi-weekly/monthly basis, or just delete the folders entirely. I assume I would use the Cron Job Manager in my host's Control Panel for this but have never used it before, would like to know what the command I would use would look like.

Have been told that answer is to simply switch to a host that does not limit the number of files allowed in a directory. I agree with that but am looking for a solution I can use now.

Thanks, Ed

31 Dec 2012, 8:32 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How to purge bmz cache folders automatically?

Disable the url rewriter that is the cause of the cache files

Zen-Venom Get Bitten

31 Dec 2012, 11:07 PM
#3
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,883
Plugin Contributions:
20

Re: How to purge bmz cache folders automatically?

:shocking: What happens if you have 1025 products! Another fully-unqualified e-commerce heard from I'm afraid.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

1 Jan 2013, 12:56 AM
#4
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: How to purge bmz cache folders automatically?

Ed, tell us what the plugin is.

If its a URL rewriter I can't help you, but if its something like image handler, i may be able to help.

although it may take a little while before I can dig out my old code

Webzings Design
Semi retired from Web Design

1 Jan 2013, 1:19 AM
#5
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: How to purge bmz cache folders automatically?

The plugin is Image Handler 4 (for v1.5.x). Seems to be working fine- the issue is with my host. I have leads on other good hosts that don't have these restrictions and will be switching when time comes, but need a solution for now. My web searches come up with a cron job that looks similar to this:

rm -rf /MYCART/bmz_cache/*

or maybe this:

'rm' -rf /MYCART/bmz_cache/*

But am thinking probably have to put the absolute path into the command, maybe something like this:

'rm' -rf /home/content/XX/XXXXXX/html/MYCART/bmz_cache/*

From what I can tell this will delete all the cache folders which will be restored when needed by IH4. Would prefer to wait until each folder was close to it's limit of 1024 then have them purged but looks to be a much more involved job.

Any advice/corrections are appreciated.

1 Jan 2013, 8:10 PM
#6
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: How to purge bmz cache folders automatically?

You could try this

It wont stop the folders going over 1024 files, but it should lessen the likelihood considerably

Instead of splitting the optimised images between 16 folder it splits them between 256 subfolders

Webzings Design
Semi retired from Web Design

1 Jan 2013, 11:06 PM
#7
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: How to purge bmz cache folders automatically?

Thanks Nigel, that looks like the ideal solution. Will do the code change and post results in the Image Handler 4 thread.

2 Jan 2013, 5:29 AM
#8
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: How to purge bmz cache folders automatically?

Instead of that, reply to this thread

so as to stop the IH thread getting off topic with unsupported mods

Webzings Design
Semi retired from Web Design