Skip to content

Instantly share code, notes, and snippets.

@gizalink
Forked from Xeroday/delete-targz.php
Created October 25, 2015 06:47
Show Gist options
  • Save gizalink/40c938f3fb7cbad3e32b to your computer and use it in GitHub Desktop.
Save gizalink/40c938f3fb7cbad3e32b to your computer and use it in GitHub Desktop.
Deletes .tar.gz files older than 7 days.
<?php
$files = glob("*.tar.gz");
foreach($files as $file) {
if(is_file($file)
&& time() - filemtime($file) >= 7*24*60*60) { // 7 days
unlink($file);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment