Share code Dọn dẹp Files lỗi trên Host
Anh em pro thì không nói làm gì...còn anh em gà gà như mình thì thật bức xúc và mệt mỏi với việc tìm xóa các file error_log trên host .
HDSD:
- Tạo file mới hoặc ghép chung với file nào mà bạn hay cron í...nó sẽ auto xóa...chỉ vậy thui à.
- Hoặc là tạo 1 file rồi set cron để auto xóa.
HDSD:
- Tạo file mới hoặc ghép chung với file nào mà bạn hay cron í...nó sẽ auto xóa...chỉ vậy thui à.
- Hoặc là tạo 1 file rồi set cron để auto xóa.
<?php
$di = new RecursiveDirectoryIterator('../');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
if(preg_match("/error_log/i",$filename))
{
$size = $file->getSize() $size;
echo $filename . ' - ' . $file->getSize()/1024/1024 . ' Mb (Đã xoá xong)
';
unlink($filename);
}
}
echo '<br>'.$size/1024/102;' Mb Xoá bởi Zenkys1';
?>
$di = new RecursiveDirectoryIterator('../');
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
if(preg_match("/error_log/i",$filename))
{
$size = $file->getSize() $size;
echo $filename . ' - ' . $file->getSize()/1024/1024 . ' Mb (Đã xoá xong)
';
unlink($filename);
}
}
echo '<br>'.$size/1024/102;' Mb Xoá bởi Zenkys1';
?>