[PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Tim Burgan
Hello,
How can I delete ALL files within a specified directory every 20 days?
Does anyone know of any code-snippets that are around at the moment that 
are able to do this? (And where I can find them?)

Thanks
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Tim Burgan
Hello,
How can I delete ALL files within a specified directory every 20 days?
Does anyone know of any code-snippets that are around at the moment that
are able to do this? (And where I can find them?)
Thanks
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Jay Blanchard
[snip]
How can I delete ALL files within a specified directory every 20 days?
Does anyone know of any code-snippets that are around at the moment that

are able to do this? (And where I can find them?)
[/snip]

Create a script that deletes files in the directory and then CRON it.

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Mikey
 How can I delete ALL files within a specified directory every 20 days?
 Does anyone know of any code-snippets that are around at the 
 moment that are able to do this? (And where I can find them?)
 
 Thanks
 
 Tim

Sounds more like a job for cron than for PHP - man crontab should set you
up...

Mikey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Greg Donald
On Tue, 15 Feb 2005 01:22:42 +1030, Tim Burgan [EMAIL PROTECTED] wrote:
 How can I delete ALL files within a specified directory every 20 days?
 Does anyone know of any code-snippets that are around at the moment that
 are able to do this? (And where I can find them?)

You can put a tmp file in there and use filemtime() to check how old
it is.  When it's 20 days old, do your deletes.  You can setup the
check on the filemtime() with cron or whatever scheduling tools you
use.

if( ( @filemtime( 'tmp_file' ) + 20 * 24 * 60 * 60 )  time() )
{
// do deletes

// make new tmp_file
}


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Robby Russell
On Tue, 2005-02-15 at 02:12 +1030, Tim Burgan wrote:
 Hello,
 
 How can I delete ALL files within a specified directory every 20 days?
 Does anyone know of any code-snippets that are around at the moment that
 are able to do this? (And where I can find them?)
 
 Thanks
 
 Tim
 

What operating system?

In linux you'd use

rm -rf /path/to/dir

and add this to crontab.

-Robby

-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
* --- Now hosting Ruby on Rails Apps ---
/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread John Nichel
Tim Burgan wrote:
Hello,
How can I delete ALL files within a specified directory every 20 days?
Does anyone know of any code-snippets that are around at the moment that 
are able to do this? (And where I can find them?)

Thanks
Tim
Write a script that will delete them, and set the script to run on a 
cron (*nix) or via the Task Scheduler (Windows).

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Delete all files in DIR every 20 days

2005-02-14 Thread Torsten Rosenberger
Hello 

take a look a the Pear File_Find class

 require_once 'File/Find.php';
 $fs = new File_Find;
 $data = $fs-maptree('my_dir');

 $data[0] contains all directorys
 $data[1] all files 

 $ok = 0;
 $err = 0;
 foreach ($data[1] as $key)
 {
   if (unlink($key)) {
$ok++;
   } else {
 $err++;
   }
 }

 if there is an error ist is not able to delete the directorys

   // the first directory (in deep) must the last one
   sort($data[0]);

foreach ($data[0] as $key)
{
  if(rmdir($key)) 
}
 
BR/Torsten

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php