'Delete dir files on every sunday 12noon
Holla,
Guys i am currently deleting sesstions if created time is more than 9 hours but i wish for it to clean the _sessions dir on every sunday at 12noon.
can someone here help me out with the logic ?
my code
$ses_dir = '_sessions/';
if ($handle = opendir($ses_dir)) {
date_default_timezone_set('America/New_York');
while (false !== ($file = readdir($handle))) {
$filelastmodified = filemtime($ses_dir . $file);
if((time() - $filelastmodified) > 9*60*60) {
unlink($ses_dir . $file);
}
}
closedir($handle);
}
really thankful for your help in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|