跳到主要內容

發表文章

精選

Linux 刪了日誌,磁碟為什麼還是滿的?看懂開啟中的檔案 / Why Deleting a Linux Log May Not Free Disk Space

刪掉的是什麼? / What was actually removed? 假設你在 Linux 伺服器刪掉一個很大的舊日誌,目錄裡已經找不到它,磁碟用量卻幾乎沒變。先別急著再刪一輪:檔名消失,不一定代表資料已經釋放。本文聚焦一種常見原因,也就是仍有程序開著那個檔案,不把所有空間問題都歸到同一個答案。 Imagine deleting a large old log on a Linux server. It disappears from the directory, yet disk usage barely changes. Resist deleting more files: a missing name does not necessarily mean the data has been released. This article focuses on one common cause—a process still has the file open—not a universal explanation for every space problem. 依 Linux 系統呼叫手冊,unlink 移除的是檔案系統中的一個名稱。只有當它是最後一個硬連結,而且沒有程序開著檔案,佔用的空間才會供重新使用。硬連結可以理解成同一份檔案的另一個名字;刪掉其中一個名字,並不是刪掉其他名字。[1] According to the Linux system-call manual, unlink removes a name from the filesystem. The space becomes reusable when that was the last hard link and no process has the file open. A hard link is another name for the same file; removing one name does not remove the others. [1] 程序開啟檔案後,會取得檔案描述符,也就是用來操作已開啟檔案的編號。即使最後一個名字被移除,只要仍有描述符指向它,檔案就會繼續存在,直到最後一個相關描述符關閉。因此,目錄中的名稱與程序手上的開啟狀態,要分成兩條線來看。[1][2...

最新文章

腳本裡 cd 成功,終端機卻沒移動?看懂 Bash 的工作目錄 / Why cd in a Script Does Not Move Your Terminal

Docker 容器為什麼不像一台完整電腦?從共用核心看懂隔離 / Why a Docker Container Is Not a Whole Computer

【實戰指南】NVIDIA GB10 (DGX Spark) 本地 AI Agent:vLLM + Qwen3.8-27B-NVFP4 + Hermes Agent 部署調優 (ZH/EN Guide)

從聊天機器人到工作夥伴:下一世代 AI Agent 的沙盒化與品質保證

別讓 AI Agent 把你的 Repo 搞崩:從『風險評估』導向的開發新範式 | Stop Letting AI Agents Wreck Your Repo: The Evaluation-First Development Paradigm

別再被 API Key 搞到肝指數爆表:用 ai-relay 打造你的 Serverless AI 流量調度中心 | Stop API Key Burnout: Building Your Serverless AI Traffic Hub with ai-relay

別讓你的 AI 寫出 2018 年的 Kotlin:Compose-Kotlin-Agent-Skills 的革命性對齊 / Stop Your AI from Writing 2018-era Kotlin: The Revolutionary Alignment of Compose-Kotlin-Agent-Skills

別讓你的專案得『失智症』:SpiderBrain V3 如何用圖論拯救 AI 時代的 Token 焦慮 | Stop Project Alzheimer's: How SpiderBrain V3 Uses Graph Theory to Cure Token Anxiety