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

How to clear disk space on CentOS

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to clear the disk space on CentOS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to clear disk space on CentOS".

The following is a quick command to clear disk space on a centos 6 or centos 7 server.

First, you need to install the yum-utils package:

Yum- y install yum-utils

1. Pruning log files

Find / var-name "* .log" ((- size + 50m-mtime + 7)-o-mtime + 30)-exec truncate {}-size 0

This truncates all files on the * .log volume / var that are longer than 7 days and more than 50m or more than 30 days.

two。 Clean up the yum cache

Cleaning the yum cache is simple:

Yum clean all

Note that the above command does not delete all files related to yum that have been installed.

You may want to free up space occupied by orphaned data in disabled or deleted repositories:

Rm-rf / var/cache/yum

In addition, when you accidentally yum through a normal user (forget sudo), yum creates a user cache. So we also delete it:

Rm-rf / var/tmp/yum-*

3. Delete orphan package

Check existing orphan bags

Package-cleanup-quiet-leaves-exclude-bin

Confirm to delete orphaned package

Now, if you are satisfied with the advice given by the previous command, run:

Package-cleanup-quiet-leaves-exclude-bin | xargs yum remove-y

4. Delete wp cli cached wordpress downloads

Each time you set up a new wordpress site, wp cli saves the wordpress archive. You can delete these caches with the following command:

Rm-rf / root/.wp-cli/cache/*rm-rf / home/*/.wp-cli/cache/*

5. Delete the old kernel

Before removing the old kernel, you may want to restart to boot from the latest kernel.

Because you can't remove the old kernel of the current boot system?

The following command retains only 2 of the latest kernels:

Package-cleanup-oldkernels-count=2

Note that for some vps providers, such as linode, the server defaults to the kernel built by the provider, not the kernel of the server itself. Therefore, there is no point in keeping more than one old kernel on the system. So:

Package-cleanup-oldkernels-count=1

6. Delete composer cach

Rm-rf / root/.composer/cacherm-rf / home/*/.composer/cache

7. Delete core dump

If you have some serious php failures that cause segment errors and enable core dumps, then chances are-you have a lot of them.

You do not need them after you have finished debugging problems. So:

Find-regex ". * / core\. [0-9] + $"-delete

8. Delete error_log file (cpanel)

If you use disgusting cpanel, you will definitely error_log to spread dozens of files in your web directory. If you can install citrus stack, that would be much better. The temporary solution is to delete all these files:

Find / home/*/public_html/-name error_log-delete

9. Delete node.js cach

Rm-rf / root/.npm / home/*/.npm / root/.node-gyp / home/*/.node-gyp / tmp/npm-* Thank you for reading, the above is the content of "how to clear disk space on CentOS". After the study of this article, I believe you have a deeper understanding of how to clear disk space on CentOS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

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

12
Report