close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Clear cache

Thread began 8/06/2014 5:35 pm by Bill | Last modified 8/07/2014 2:19 am by Bill | 386 views | 3 replies

Jamie

Hey Bill

I run a cron job every night on my sites to delete the image cache folder contents.

If it helps, here's the details

The script code is

<?php


define('PATH', 'images/image_cache/');

function destroy($dir) {
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir))) {
if($file != "." && $file != "..") {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir('.');
destroy($dir.$file.'/');
rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
else
unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
}
closedir($mydir);
}
destroy(PATH);
echo 'all done.';


?>



Modify the line 'images/image_cache/' to point to the folder you wish to empty of content (it doesn't delete the folder just the contents)
If you want to empty multiple folders, just add more define('PATH', 'images/folder2/'); lines and adjust accordingly like this

<?php


define('PATH', 'images/folder1/');
define('PATH', 'images/folder2/');
define('PATH', 'images/folder3/');

function destroy($dir) {
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir))) {
if($file != "." && $file != "..") {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir('.');
destroy($dir.$file.'/');
rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
else
unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
}
closedir($mydir);
}
destroy(PATH);
echo 'all done.';


?>



Just add that code script to a blank php file and save it - I name mine delete.php so I can tell quickly what it does!

Upload it to the root of your site

Go to your cpanel for the site and got to the cron section and add a cron job - I run this one once a day and typically set it to run in the wee hours. I set mine to run at 3:41 am (if you're on a shared server, other resources are typically being run by other sites in the hour or half hour so this reduces your cron job from not running)

The path you need to run the cron will depend on your host but this is one of mine so you can see the structure

/usr/bin/php /home/ybgorrvn/public_html/delete.php

Hope that this helps...if you have any questions do get in touch

All the best

Jamie

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...