Skip to content

Instantly share code, notes, and snippets.

@leonirlopes
Forked from Xeroday/delete-targz.php
Created March 23, 2017 11:53
Show Gist options
  • Save leonirlopes/06a73f178398db7ade751ea0cff083c3 to your computer and use it in GitHub Desktop.
Save leonirlopes/06a73f178398db7ade751ea0cff083c3 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