View Single Post
Old 10-21-2009, 01:15 PM  
Naughty
Confirmed User
 
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,479
php code snippet guru's, please ...

I have this to kill some older files, backups...

PHP Code:
$dir '/www/';
if (
$handle opendir($dir)) {

  while (
false !== ($file readdir($handle))) {
    if (
$file[0] == '.' || is_dir("$dir/$file")) {
      continue;
    }
    if ((
time() - filemtime($file)) > ($days *86400)) { //7 days
      
unlink("$dir/$file");
    }
  }
  
closedir($handle);


Any idea how i can change this
"kill all older than 7 days",
into
"kill all BUT the latest three" <- so, could be there's one in there that is weeks old, as long as no new ones appear

I have had TM3 break and the kill older than x days backups. When we found out TM3 was broken, it had also killed all good backups already

Anyone? We're going to cron this.
__________________
seks.ai for sale - ping me
Naughty is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote