Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 923
samarth Avatar asked Dec 14 '11 11:12

samarth


People also ask

Can I delete dead letter file?

The dead-letter queue doesn't need to be explicitly created and can't be deleted or managed independent of the main entity.

Can I delete dead letter in Linux?

You can delete a message from a dead-letter queue directly from the Dead-Letter Queue Messages workspace.

What is root dead letter?

The Dead Letter mailbox stores messages that could not be added to a regular mailbox. The Dead Letter mailbox is located under the root mailbox as /DeadLetter.

What does dead letter mean in Linux?

letter is usually created by mail client such as /usr/bin/mail, when you abort the message being sent, a copy of the message will be saved in your home folder: dead.


3 Answers

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.

like image 102
fge Avatar answered Oct 11 '22 16:10

fge


You know about lsof (http://linux.die.net/man/8/lsof) ?

In this case:

sudo lsof /root/dead.letter

This prints out info's about the process having the file open. You still have to kill that process.

like image 5
Nils Ballmann Avatar answered Oct 11 '22 14:10

Nils Ballmann


If the above script does not work, One can just think of the processes which might be having the handle to such files occupying space in root or home directory.

Kill such processes and the disk space will be freed

You can use (ps -ef | grep process_name) to find out the process id.

like image 1
samarth Avatar answered Oct 11 '22 16:10

samarth