Linux 如何删除根目录中没有可用空间的“死信”文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8503626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove "dead.letter" File which left no free space in root directory
提问by samarth
- Today I noticed that dead.letter file is created in my root directory on one of the EC2 instances.
- After some look up I came to know that this is created because of some incomplete or terminated email functionality.
- It has size of 6 GiB and it left no free space in root directory.
- I have deleted the file still my root directory shows no free space available.
- 今天我注意到在我的一个 EC2 实例的根目录中创建了 dead.letter 文件。
- 经过一番查找,我才知道这是由于某些不完整或已终止的电子邮件功能而创建的。
- 它的大小为 6 GiB,并且根目录中没有可用空间。
- 我已经删除了文件,但我的根目录显示没有可用空间。
Any idea how to remove this file and free up the root space?
知道如何删除此文件并释放根空间吗?
采纳答案by fge
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:
尝试使用以下方法查找进程的 PID:
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.
然后杀死它/他们。
回答by samarth
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.
您可以使用它 (ps -ef | grep process_name)
来找出进程 ID。
回答by Nils Ballmann
You guys know about lsof
(http://linux.die.net/man/8/lsof) ?
你们知道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.
这会打印出有关打开文件的进程的信息。您仍然必须终止该进程。