Skip to content

Instantly share code, notes, and snippets.

@awsp
Forked from Xeroday/delete-targz.php
Last active July 6, 2016 19:10
Show Gist options
  • Save awsp/79fc5d6f027651fa9a38148ba1daa781 to your computer and use it in GitHub Desktop.
Save awsp/79fc5d6f027651fa9a38148ba1daa781 to your computer and use it in GitHub Desktop.
Deletes .tar.gz files older than 7 days.
<?php
$files = glob("*.tar.gz");
$days = 7;
foreach($files as $file) {
if(is_file($file)
&& time() - filemtime($file) >= $days*24*60*60) {
unlink($file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment