/**
* 清理今天以前的logs文件
*/
$time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$dir = '../logs';
$delete_count = 0;
if(is_dir($dir))
{
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..')
{
$file_dir = $dir . '/' . $file;
var_dump($file_dir);
if(filemtime($file_dir) < $time)
{
$status = unlink($file_dir);
if( !$status )
{
echo 'fail';
}
else
{
$delete_count++;
}
}
}
}
echo 'delete file count is ' . $delete_count;
closedir($dh);
}
}