Search code examples
linuxemailunixfilesystemsroot

How to remove "dead.letter" File which left no free space in root directory


  1. Today I noticed that dead.letter file is created in my root directory on one of the EC2 instances.
  2. After some look up I came to know that this is created because of some incomplete or terminated email functionality.
  3. It has size of 6 GiB and it left no free space in root directory.
  4. I have deleted the file still my root directory shows no free space available.

Any idea how to remove this file and free up the root space?


Solution

  • If you have removed it and the space still isn't freed, then it means a process has a file handle opened on it.

    Try and find the PID of the process using, for instance:

    for process in /proc/[0-9]*; do
        for fd in $process/fd/*; do
            file=$(readlink -f $fd)
            if [ "$file" = "/root/dead.letter" ]; then
                echo $process
            fi
        done
    done
    

    Then kill it/them.