Linux disk space View Inode

Source: Internet
Author: User
Tags system log

Server is generally required for long-term continuous operation, automatic task generated by the various files and logs, may make space full, resulting in business failures, so to regularly clean up.

In general, there are two types of Linux space:

1, the space is occupied

With DF-K can see use 100%, in this case, the full partition cannot create a new file, also cannot output the log, the process that needs to lose the log will generally stop working

2, the inode is full

How does the inode understand that a file corresponds to an inode, and that the inode available for each partition of Linux is generally limited, using df-i to view usage. Usually the hard disk space is not full, but the inode is full, this is generally because there are a large number of small files generated, to delete

To clean up the space on a regular basis, we need to know a command, the Find command, which can query the directory for a specific file name and generate a date.

Examples are as follows:

find/slvi/apache/htdocs/nos/netflow/netflow/view/report/day/r-nf-543*-type F-mtime +10

The above is the query/slvi/apache/htdocs/nos/netflow/netflow/view/report/day/directory under the file name open r-nf-543 files

-type f indicates the file, as-D just is the directory,-mtime +10 is more than 10 days now, if 10 days, 10

Above is just a query, we need to find out, and then delete, then add "-exec rm-rf {} \;", the results are as follows:

find/slvi/apache/htdocs/nos/netflow/netflow/view/report/day/r-nf-541*-type f-mtime +10-exec rm {} \;

For General Linux,/var is a variety of system log output partition, it is recommended not with the root partition, but separate partition, generally we draw 20G (generally enough, unless you are passionate about analyzing the log), generally we want to clean up some of the following files and directories/var/:

/bin/echo ' >/var/spool/mail/root if your/var space is often not enough, you can clear it, of course, the users of your application should also clear:

/bin/echo ' >/var/spool/mail/xxxx XXXX for your average user

The following two are usually sent in the mail queue, need to clean up, or may cause/var/full, or inode full, because many small files:

/bin/find/var/spool/clientmqueue/*-type f-mtime +7-exec rm-rf {} \;

/bin/find/var/spool/mqueue/*-type f-mtime +7-exec rm-rf {} \;

It says it's 7 days clear.

/var/log/The following many logs are circular, generally save 4 files, on the system analysis is very important, so can according to their own situation, decided to clear and unclear, or save how long:

Echo ' >/var/log/maillog.3 The third file, the longest from the most recent time

/var/log/messages.3 clear the third file, the most recent time

The above command can be placed in a unified shell, and then put the shell into the crontab to run automatically. Of course you need to observe for a long time and find other clear, also put into the shell, including your own application output logs and files.

Also remind, to use Find, do not add the following delete command, first look to find out whether it is correct, whether you need to delete, and then remove, lest you in the root directory execution RM-RF *

Linux disk space View Inode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.