Preface
At work, I often encounter insufficient disk space in Linux systems. However, after deleting larger log files, I find that the disk space has not been released yet. I am a little confused. Today, the blogger will help you solve this problem.
Ideas
1. At work, it is found that there is insufficient disk space;
2. Find files that occupy a large amount of disk space and delete them;
3. After deleting the file, check the disk space usage and it is not released;
4. Find the corresponding delete process, kill it, and the problem is solved.
Specific operations
View server disk space usage
df -h /
du -sh ./*How
to release such space
There are many ways to solve this type of problem and free up space: restart the occupied process, restart the operating system, and pass commands. The first two methods are most convenient for non-production environments, but for production environments, it is better to use commands as much as possible. In fact, the commands are also very simple: you can use the lsof command to
obtain a list of files that have been deleted but are still occupied by the program:
lsof | grep delete
kill -9 pid
lsof | grep -w deleted | awk ‘{
print $2}’ | xargs kill
In actual production, I encountered that the log has been deleted for half a month but the disk space has not been released. Through lsof | grep delete naming, it was found that the process was hung up by vector log collection. Restart vector and the disk space returned to normal.