How to empty (“truncate”) a file on linux that already exists and is protected in someway?

后端 未结 9 501
梦谈多话
梦谈多话 2020-12-12 12:39

I have a file called error.log on my server that I need to frequently truncate. I have rw permissions for the file. Opening the file in vi > deleting all content > saving wo

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 13:31

    the credit goes for my senior colleague for this:

    :> filename
    

    This will not break log files, so you can even use it on syslog, for example.

提交回复
热议问题