How to remove the file "dead.letter", which did not leave free space in the root directory

  • Today I noticed that the dead.letter file is being created in my root directory in one of the EC2 instances.
  • After some searching, I found out that it was created due to some incomplete or discontinued email functions.
  • It has a size of 6 GiB and leaves no free space in the root directory.
  • I deleted the file, but my root directory does not show free space.

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

+6
source share
3 answers

If you deleted it and the space is still not freed, then the process has a file descriptor open on it.

Try to find the PID of the process using, for example:

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 him / them.

+7
source

Do you guys know about lsof ( http://linux.die.net/man/8/lsof )?

In this case:

 sudo lsof /root/dead.letter 

Information about the process of opening the file is displayed here. You still have to kill this process.

+2
source

If the above script does not work, you can just think of processes that may have a descriptor for such files occupying space in the root directory or in the home directory.

Kill these processes and disk space will be freed

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

+1
source

Source: https://habr.com/ru/post/903757/


All Articles