為什么vi編輯后文件的Birth Time也會(huì)變?

1、問(wèn)題現(xiàn)象

VI編輯后 Acess、Modify、Change和Birth Time都會(huì)變


image.png

其原因是 vi后,文件的inode會(huì)發(fā)生變化


image.png

這種情況如果發(fā)生在日志文件上,就會(huì)出現(xiàn)新日志不會(huì)記錄到日志文件,而且日志空間還會(huì)繼續(xù)上漲


image.png

2、inode為什么會(huì)變?

缺省情況下,backupcopy=auto,一般是no,也就是會(huì)寫(xiě)一個(gè)新文件

'backupcopy' 'bkc'      string  (Vi default for Unix: "yes", otherwise: "auto")
                        global or local to buffer |global-local|
                        {not in Vi}
        When writing a file and a backup is made, this option tells how it's
        done.  This is a comma separated list of words.

        The main values are:
        "yes"   make a copy of the file and overwrite the original one
        "no"    rename the file and write a new one
        "auto"  one of the previous, what works best

        Extra values that can be combined with the ones above are:
        "breaksymlink"  always break symlinks when writing
        "breakhardlink" always break hardlinks when writing
3、如何讓inode不變
  • 在vi中設(shè)置 :set backupcopy=yes
  • 在vimrc (全局或者文件中設(shè)置)
  • 給文件創(chuàng)建硬鏈接
4、已經(jīng)vi編輯過(guò)的日志如何找回
  • 通過(guò)cp /proc/xxxx/fd/xxxx xxx 找回丟失的日志
  • 找回后重啟應(yīng)用,日志會(huì)定位到新的文件
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容