「操作系统」- 文件截断

这个问题是由群里的一个问题引发的:如何截断日志文件?后来有人说,使用>>写入的文件,可以直接截断。

相关关键字

清空文件

> 与 >>>

O_APPEND 与 O_WRONLY

lsof -nP +f g | grep ,AP

相关连接

# 下面的几篇帖子要好好读一下
Emptying a file without disrupting the pipe writing to it
Linux Programmer’s Manual/open, openat, creat – open and possibly create a file
What happens when I truncate a file that is in use?

# 这些文章也需要读一下
how to empty or truncate a file in linux

# 这几篇帖子看看就好了
Truncating a file while it’s being used (Linux)