IPB
Your Ad Here


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
help with cache file-deleting script
Misha Singh
post Nov 3 2009, 05:27 PM
Post #1


Advanced Member
***

Group: Members
Posts: 7,885
Joined: 23-November 08
Member No.: 6,521



Hello, I am trying to make a script that I can run via Cron to delete all the files in a specific cache folder.
I have this:


PHP Code:





<?php

$files
= array();

$index = array();

$yesterday = strtotime('yesterday');


if (
$handle = opendir('cache_chaindlk')) {

clearstatcache();

while (
false !== ($file = readdir($handle))) {

if (
$file != "." && $file != "..") {

$files[] = $file;

$index[] = filemtime( 'cache_chaindlk/'.$file );

}

}

closedir($handle);

}

asort( $index );


foreach(
$index as $i => $t) {

if(
$t < $yesterday) {

@
unlink('cache_chaindlk/'.$files[$i]);

}


}

?>






Doesn't seem to work.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
Tags
No Tag inserted yet

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st November 2009 - 04:37 PM
Your Ad Here