Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arunjayakumar01/5ed43047ed16addbca2738acecae77b9 to your computer and use it in GitHub Desktop.
Save arunjayakumar01/5ed43047ed16addbca2738acecae77b9 to your computer and use it in GitHub Desktop.

Kill Process that keeps the diskspace after deleteing the files

  • Some process keeps the diskspce after the files are deleted , these are usually solved by restarting the servers , to avaoid the downtime use this command. this will kill all the process holding the disk space.

    kill -9 $(lsof +L1 | awk -F ' ' '{print $2}')
    
  • The inode, which is a structure that holds the list of said blocks, and some metadata (size, ownership, permissions, link count, and some others).

  • When you delete a file (e.g. using rm), you're not actually deleting the file, you're deleting the directory entry. The kernel decrements the inode's link count, but doesn't delete the inode (and reclaim space) unless:

    • that directory entry was the last one pointing to it (i.e. link count is down to zero - this is what lsof +L1 lists: open files that are completely unlinked)
    • there are no remaining open file descriptors that refer to it

So processes can continue operating on that file, even if there is no way to get back to it from browsing the filesystem. And you can get apparent inconsistencies from the output of df and du

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment