Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of cleaning disk by linux

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail the methods of linux disk cleaning for you. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. View disk information

Df-lh

We can see that the 40G capacity under the mount point / dev/xvda1 under Filesystem has been exhausted. The next step is to delete files that take up a lot of disk space but are useless.

2. Locate the largest file directory

Cd / # goes to the root directory. Du-h-max-depth=1 # looks for the current directory and which folder takes up the most space

You can see that / usr this path takes up a lot of disk space and takes up 21G. Sharp-eyed students may see the last item showing 24g, which indicates that the total disk space occupied by all files in the current directory is 24g.

Do the same, after several judgments, locate the log file of tomcat.

Judging from the above figure, the 17G file is in the current directory (tomcat log directory) file.

3. Locate the largest file

Ls-lhS # presents files in order from largest to smallest

The final location file is: catalina.out this log file.

4. Confirm that the file is not occupied

Anyone can delete a file: rm-f catalina.out, but it's best to make sure you want to download it and let the developer analyze the log.

In Linux or Unix systems, deleting files through rm or file manager will unlink (unlink) from the directory structure of the file system. However, if the file is opened (there is a process in use), the process will still be able to read the file and disk space will always be occupied.

/ usr/sbin/lsof | grep deleted # confirm whether the deleted file is occupied

It is indeed occupied. According to the pid provided in the second column, enter the command: kill-9 13117 to kill the process.

Enter the command again: df-lh

As shown in the figure, disk space is freed. The problem was dealt with smoothly.

On the linux disk cleaning methods to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report