1、当我们用远程工具连接Linux操作系统用vim编辑文件的时候,由于集群的不稳定,或打开后忘记关闭了,或非正常断开的时候。当我们再次编辑此文件的时候就会出现如下所示的提示:
[root@localhost scripts]# vim rsync+inotify.sh E325: ATTENTION Found a swap file by the name ".rsync+inotify.sh.swp" owned by: root dated: Fri May 17 18:49:14 2019 file name: /server/scripts/rsync+inotify.sh modified: YES user name: root host name: localhost.localdomain process ID: 17081 (still running) While opening file "rsync+inotify.sh" dated: Fri May 17 18:45:31 2019 (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 rsync+inotify.sh" to recover the changes (see ":help recovery"). If you did this already, delete the swap file ".rsync+inotify.sh.swp" to avoid this message. Swap file ".rsync+inotify.sh.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
这是由于已经打开但未关闭的文件,会在其目录下出现一个.swp的文件,由于是属于隐藏文件,可以用命令“l.”对其进行查看。需要将该.swp文件进行删除,才不会出现上述中的那些提醒。
2、解决方案
查看并删除.swp隐藏文件
[root@localhost scripts]# l. . .. .rsync+inotify.sh.swp [root@localhost scripts]# rm -rf .rsync+inotify.sh.swp
由于是隐藏的文件,所以不能够使用rm -rf *.swp这样的形式进行删除;
但是可以使用语句:rm -rf .*.swp 的形式进行删除
删除该文件的.swp隐藏文件之后就可以正常打开和编辑该文件了。
[root@localhost scripts]# vim rsync+inotify.sh #!/bin/bash #qq:1431975440 #rsync+inotify serverID=10.90.3.115 back_path=/data rsync_module=oldboy rsync_user=rsync_backup rsync_passwd=/etc/rsync.password inotify_path=/opt/inotify/bin/inotifywait