.swp文件


.swp文件是由vi编辑器产生的缓存文件。当你用vi打开一个文件(如:AAA.BB)时,vi会自动生成一个swp文件以防意外(.AAA.BB.swp)。当你正常退出后,vi编辑器会自动将这个swp文件删除。

有2种情况会导致swp文件无法自动删除:1. 当多个程序同时编辑一个文件时;2. 当vi非正常退出时。当你下次编辑的时候,会出现下面的提示:

E325: ATTENTION Found a swap file by the name “.rsyncd.conf.swp” owned by: root dated: Thu Jan 7 14:02:51 2016 file name: /etc/rsyncd.conf modified: no user name: root host name: BBS-Backup process ID: 10109 (still running) While opening file “rsyncd.conf” dated: Wed Jan 6 11:34:40 2016

(1) Another program may be editing the same file. If this is the case, be careful not to end up with two different instances of the same file when making changes. Quit, or continue with caution.

(2) An edit session for this file crashed. If this is the case, use “:recover” or “vim -r rsyncd.conf” to recover the changes (see “:help recovery”). If you did this already, delete the swap file “.rsyncd.conf.swp” to avoid this message. “rsyncd.conf” 0L, 0C Press ENTER or type command to continue

提示swap文件已存在,可能是多个进程导致的,也可能是文件已损坏。

解决方案如下:

vi -r AAA.BB #将该文件恢复
rm .AAA.BB.swp    #删除缓存文件