使用 truncate 命令清空文件

1 min read

truncate命令将文件的大小缩小或扩展到定义的大小。

你可以将它与-s指定文件大小的选项一起使用。要清空文件内容使用-s 0参数。

truncate -s 0 access.log