使用df -h命令查看空间使用情况,磁盘空间使用了100%。
常规方法,清日志、删除无用的文件。删除后再次查看空间大小。
现在遇到的情况是,使用du --max-depth=1 -h / 命令查看,各目录使用空间总和只占空间一部分,远没有达到100%的使用率。
原因:系统的磁盘空间没有被释放,这可能是因为忽略了一些应用程序一直在向其写入数据,直接删除文件无法释放磁盘空间。
[En]
Reason: the disk space of the system is not released, which may be due to the neglect of the fact that some applications have been writing data to it, and deleting a file directly cannot free disk space.
操作步骤:
1、执行 lsof | grep deleted 发现有大量刚刚删除文件的进程存在,kill掉进程(或者重启进程)
2、lsof | grep deleted |wc -l 可以看到有多少个进程。
3、需要kill进程数量多时,使用命令。
lsof | grep deleted | awk '{if (NR > 1){print $2}}'|uniq | xargs kill -9
awk '{if (NR > 1){print $2}}',获取第二列