Truncating a file while it's being used (Linux)

后端 未结 13 2152
名媛妹妹
名媛妹妹 2020-12-05 01:54

I have a process that\'s writing a lot of data to stdout, which I\'m redirecting to a log file. I\'d like to limit the size of the file by occasionally copying the current

13条回答
  •  爱一瞬间的悲伤
    2020-12-05 02:42

    I downloaded and compiled the latest coreutils so I could have truncate available.

    Ran ./configure and make, but did not run make install.

    All the compiled utilities appear in the "src" folder.

    I ran

    [path]/src/truncate -s 1024000 textfileineedtotruncate.log

    on a 1.7 GB log file.

    It did not change the size listed when using ls -l, but it did free up all the disk space - which is what I really needed to do before /var filled up and killed the process.

    Thanks for the tip on "truncate"!

提交回复
热议问题