dylan
11/7/2017 - 9:45 AM

Automatic delete certain files type in a folder

Shell script

## Automatic cleanup Cache folder
$files = glob('cache/'."*.mp3");
  $time  = time();

  foreach ($files as $file)
    if (is_file($file))
      if ($time - filemtime($file) >= 60*60*24*2) // 2 days
        unlink($file);
#==================================