Created
June 24, 2018 01:37
-
-
Save rochow/5c6f7a8823c6d5493160e7073be99d63 to your computer and use it in GitHub Desktop.
Simple cleanup script to remove files in a directory older than X days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = glob("*"); | |
$time = time(); | |
$ignore = array('cleanup.php','.ftpquota','index.html','robots.txt'); | |
foreach($files as $file) { | |
if(is_file($file) && !in_array($file,$ignore)) { | |
if($time - filemtime($file) >= 60*60*24*30) { // 30 days | |
unlink($file); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment