Deleting log file space does not free up space

The problem that the space of the deleted log file is not released can be solved in this way. The

main reason is that deleting the file under Linux is to delete the space occupied mark in the inode node, which can be understood as deleting the file pointer. If the file pointer is being used by the process, it will not be deleted.

Therefore, there will be cases where the file space is still not released even if the file space is deleted.


echo ' ' > a.log


sudo -u admin sh -c "echo ' ' > a.log" The reason for adding sh -c is that sudo only has permission to echo and > does not authorize

sh -c to read from a string to execute Command, the same is true for executing shell commands in Java, you need to add /bin/sh -c command to execute.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326489705&siteId=291194637