设置log权限 我懒得弄直接777
定时执行下面的方法就可以了
public function clear_log_chache() {
$this->delDirAndFile('/www/wwwroot/tzzzdj.1qqqq.com/runtime/log');
// foreach ($path as $item) {
// array_map( 'unlink', glob( $item.DS.'.' ) );
// rmdir( $item );
// }
$this->success( '清除成功', 'index/index' );
}
public function delDirAndFile($path, $delDir = FALSE)
{
if (is_array($path)) {
foreach ($path as $subPath){
$this->delDirAndFile($subPath, $delDir);
}
}
if (is_dir($path)) {
@mkdir($path,0777,true);
$handle = opendir($path);
if ($handle) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..")
is_dir("$path/$item") ? $this->delDirAndFile("$path/$item", $delDir) : unlink("$path/$item");
// {
// dump("$path/$item");
// die;
// }
}
closedir($handle);
if ($delDir)
return rmdir($path);
}
} else {
if (file_exists($path)) {
return unlink($path);
} else {
return FALSE;
}
}
clearstatcache();
}