Re: Unlinking files.
| From: | David Otton | Date: | Wed, 24 Dec 2003 11:44:38 +0000 |
| Subject: | Re: Unlinking files. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173292@lists.php.net to get a copy of this message | ||
On Tue, 23 Dec 2003 19:08:28 -0800 (PST), you wrote:
>>How can I unlink files in a directory that are, for example older than 1
>>hour?
>
>
find /path/to/dir -cmin +60 -type f -print0 | xargs -0 rm -f;
Alternatively, for cross-platformness user opendir() and readdir() to
iterate over the directory, stat() or filemtime() to grab the last-modified
time of the file, and unlink() to remove files where ($last_modified <
time() - 3600).