最近項目異常查找原因,發現伺服器 的磁盤空間占用100%
原來是一個項目打包下載下傳的臨時檔案夾滿了。
之前沒有考慮到這個問題,隻能補一下漏洞。
解決方案:每次下載下傳前把過期檔案清空,這樣就不會占用磁盤空間了。
/*批量下載下傳*/
public function download_project($array)
{
// 循環删除過期檔案 start
$tmp = 'tmp_down';
$savepath1 = '../public'.$tmp;
$path1 = dir($savepath1);
while (($item = $path1->read())!=false) {
if($item=='.' || $item=='..'){
continue;
}else{
$file = $savepath1.'/'.$item;
$times = time()-filemtime($file);
if($times>24*3600){
unlink($file);
}
}
}
// 循環删除過期檔案 end
若有幫助到您,歡迎點選推薦,您的支援是對我堅持最好的肯定(*^_^*)
你要保守你心,勝過保守一切。
作者:劉俊濤的部落格