Methods of clearing disk space on CentOS 6 or CentOS 7
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 will truncate 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 cannot 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-*
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.