Linux Basic Learning -9.6-file deletion principle

Source: Internet
Author: User
Tags rsyslog

1, the principle of file deletion

RM Delete file deletes only the file name

2, Control file deletion: The following two conditions at the same time to take effect

1, the number of hard links file, there is a hard link i_link +1 reduce a hard link, i_link-1

2, whether there is a process occupied using this file, there is a process to occupy this file, i_count+1

When there is no process call i_count=0

When I_link=0 and i_count=0, the file is deleted

3, file deletion, disk space does not release the reason

1, Hardlink

2. Another process is still using this file

3, disk free space maintenance problems

LN source target

[email protected] application]# LL

Total 4

-rw-r--r--1 root root 0 Mar 11:16 a

lrwxrwxrwx 1 root root 11:03 Apache--/application/apache2.2.17

Drwxr-xr-x 2 root root 4096 Mar 23:41 apache2.2.17

[[Email protected] application]# LN a b

[email protected] application]# LL

Total 4

-rw-r--r--2 root root 0 Mar 11:16 a

lrwxrwxrwx 1 root root 11:03 Apache--/application/apache2.2.17

Drwxr-xr-x 2 root root 4096 Mar 23:41 apache2.2.17

-rw-r--r--2 root root 0 Mar 11:16 b

[[Email protected] application]# LN b c

[email protected] application]# LL

Total 4

-rw-r--r--3 root root 0 Mar 11:16 a

lrwxrwxrwx 1 root root 11:03 Apache--/application/apache2.2.17

Drwxr-xr-x 2 root root 4096 Mar 23:41 apache2.2.17

-rw-r--r--3 root root 0 Mar 11:16 b

-rw-r--r--3 root root 0 Mar 11:16 C

[Email protected] application]# ll-i

Total 4

393238-rw-r--r--3 root root 0 Mar 11:16 a

393237 lrwxrwxrwx 1 root root [Mar] 11:03 Apache--/application/apache2.2.17

393236 drwxr-xr-x 2 root root 4096 Mar 23:41 apache2.2.17

393238-rw-r--r--3 root root 0 Mar 11:16 b

393238-rw-r--r--3 root root 0 Mar 11:16 C

4, disk space is full but inconsistent with the results of du-sh---not been completely removed the first milestone in the troubleshooting process-what is the reason:

# # # #已经删除了, but the space is not released

# # # #已经删除了-----The number of hard links to the file is 0

# # # # #空间没有释放---Someone else is using---process

Second milestone-Troubleshooting methods:

# lsof |grep Delete

RSYSLOGD 1250 Root 1w REG 8,3 1888889326 274029/var/log/messages (Deleted)

# # # # #硬链接数为0了, but there's another rsyslog software in use

# # #这个文件没有被彻底删除

Third Milestone-workaround

# #重启对应的软件/Service can be

#/etc/init.d/rsyslog Restart

Shutting down system logger: [OK]

Starting system logger: [OK]

Fourth milestone-Check results

# df-h

Filesystem Size used Avail use% mounted on

/dev/sda3 8.8G 1.6G 6.8G 19%/

Tmpfs 931M 0 931M 0%/dev/shm

/DEV/SDA1 190M 40M 141M 22%/boot

/DEV/SDC 73K 14K 55K 21%/app/logs

Fifth Milestone-Summary

1. Try emptying the log file without deleting

2. Cut the log, delete the old file (a few days ago)

5, the file deletion principle, the process calls the file, but the file hard link number is 0, the file has not been freed, the disk full fault http://oldboy.blog.51cto.com/2561410/612351 The practice question:

1, the principle of file deletion

2, disk space is full but the results of the DU-SH is not consistent---not completely removed the troubleshooting process

Linux Basic Learning -9.6-file deletion principle

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.