File::removeExpiredFile
Remove the files older than a number of minutes
Description
public bool File::removeExpiredFile( string $path, int $min )
Deletes the files directly under $path whose modification time is $min minutes ago or older. Subdirectories are not touched.
Returns true when every expired file was removed (also when there was none), false when $path is not a directory or a file could not be removed.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $path | string | Target directory | |
| $min | int | Age in minutes after which a file is deleted |
Example
Controller
use Fegg\Tool\File;
$file = new File();
// Delete temporary files older than one day
$file->removeExpiredFile('path/to/tmp', 60 * 24);