Home >System Tutorial >LINUX >How to delete large files under centos? How to delete large files under centos

How to delete large files under centos? How to delete large files under centos

WBOY
WBOYforward
2024-01-10 08:25:51729browse

Today I found that the disk space of the test server was 100% used. Through df -lh and du –sh, the jenkins log file 363G is located. I found several methods on the Internet about deleting large files:

1. The lowest: rm

rm After deleting the large file, df –lh will find that the disk is still occupied.

This is because when rm deletes a file, the file is generally not written to the disk immediately, that is, the space is not released immediately.

Solution:

1. Restart the server (it is best not to choose);

2.losf | grep deleted; View deleted processes

How to delete large files under centos? How to delete large files under centos

The process is not closed, so the disk space will not be released. Kill –9 PID is required. The space will not be released until the process is killed.

2. Input redirection:

The following methods all clear the file contents, but they will not delete the file

1. echo >/path/to/somefile

2. cat /dev/null > /path/to/somefile

3. >/path/to/somefile

4 : >/path/to/somefile

The above is the detailed content of How to delete large files under centos? How to delete large files under centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete