My data.txt is generated each time when someone is visiting my site. I would like to delete this file on on specific time, let say 1:00AM daily. I found this script but I'm struggling to update the code :/ Any advice?
<?php
$path = dirname(__FILE__).'/files';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filectime($path.'/'.$file)) < 86400) { // 86400 = 60*60*24
if (preg_match('/\.txt$/i', $file)) {
unlink($path.'/'.$file);
}
}
}
}
?>