Don't kill the poor process

User gets a warning about disk, sees it’s full and starts to investigate. After removing few GB’s, there is a little problem: df and du commands’ conflicting output.

Where is my free disk?

After searching it on Google, people says “check out lsof | grep deleted” and user realizes this is really a thing on Linux. Processes hold files on disk even the files are deleted. Restarts the process, and everything seems fine now.

But why?

Doing something without understanding first, grinds my gears. I’d never let the soul who chmod 777’s root recursively to touch the keyboard again. I understand this case is not that serious but after a bit digging in the /proc, I’ve found a way to rescue the process’ life!

  • Find the process’ PID which keeps the files for itself
  • Go to /proc//fd
  • Run ls -la | grep deleted and find the deleted file’s link (let’s say “13”)
  • Redirect something to the link: echo "ok" >| 13
  • Check lsof again, you won’t need to get blood on your hands anymore.

Gürkan

linux

174 Words

2016-06-21 18:02 +0200