linux truncate 文件

来源:互联网 发布:台湾淘宝花种子 编辑:程序博客网 时间:2024/05/17 23:34


某个数据库因为开发使用的是短连接,listener.log文件无限膨胀,已经达到了47G,如果rm -f 考虑文件较大,可能对系统io造成影响。

在同事的介绍下,改使用 truncate命令


安装过程如下:

wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.9.tar.gz 

tar -zxvf coreutils-8.9.tar.gz 

cd coreutils-8.9 

./configure 

make 

sudo cp src/truncate /usr/bin/ 


使用方式

truncate -s 40G listener_20130305.log

truncate -s 30G listener_20130305.log

truncate -s 20G listener_20130305.log

truncate -s 10G listener_20130305.log

truncate -s 1G listener_20130305.log

rm -f  listener_20130305.log


文件平稳删除,对系统造成压力可忽略。

0 0