Today, a certain electrical and technical department leader found a problem, said their server hard drive full. The log files are deleted, but the hard disk space is still full. So df-h looked at the status of each mount point below (pictured below).
/dev/sda3 occupies 100%, then we du-s-H./* Look at the occupancy of the catalog (figure below).
Linux disk mount point directory occupancy (figure)
The sum of the directories under the mount point is much less than 4.5G, so what is taking up the hard drive?
Here's the answer to the question:
When the Apache/tomcat service is running, it clears the log of the running service, causing the problem of/dev/sda3 full. In general, most services, including scripts, are not able to delete the log files that are currently being written while they are running.
Principle Analysis:
1. The current Access.log log is being occupied by the Apache process.
2. Delete Access.log through the RM command, which actually deletes only the file name (the log file applies a count of not 0, so the space is not freed).
3. After removing access.log through the RM command, Apache still writes logs to Access.log, and when the Apache process is turned on, it has been positioned through Access.log to the inode of the file, which means that the log is not passed through access.log, so even if you delete access Log,apache still writes logs to the Inode node where the access.log resides, resulting in increased disk space.
4. Because the deletion of the access.log, so we can not find the file, Du also can not find, there will be a hard drive full but do not see what files are occupied.
(Write not very detailed, do not understand everyone again Google.) )
Workaround:
Restart the log file related services or programs, such as: Apache Log files Restart Apache (the following figure, restart only after the hard disk space occupy normal).