目录

Vim查看文件报错

发现问题

之前使用xshell编辑文件时xshell卡住,无奈关闭xshell标签重新来过,再次vim查看文件报错

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
E325: ATTENTION
Found a swap file by the name "/var/opt/gitlab/gitlab-rails/etc/.gitlab.yml.swp"
          owned by: root   dated: Tue Jun  1 09:24:28 2021
         file name: /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
          modified: YES
         user name: root   host name: 111.47.28.118
        process ID: 10535 (still running)
While opening file "/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml"
             dated: Thu Apr  8 01:26:02 2021

(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 /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/var/opt/gitlab/gitlab-rails/etc/.gitlab.yml.swp"
    to avoid this message.

Swap file "/var/opt/gitlab/gitlab-rails/etc/.gitlab.yml.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

解决思路

这是由于之前我的编辑这个文件的时候卡顿了,所以在交换区产生了文件,并没有对源文件覆盖,

我修改的东西是按照文档改的,而且并没有很多,于是就把交换区的文件删除了就拉到,要是修改了很多建议看一下对比一下两个文件的区别,在觉得删除或是剪切过来继续用都行,剪切过来记得改名字就行

解决办法

删除指令

1
rm /var/opt/gitlab/gitlab-rails/etc/.gitlab.yml.swp

在编辑就没有报错了

反思

Linux文件修改机制,先再交换区创建副本,进行编辑,执行保存的化就从暂存区把文件弄过来。一旦出现了问题,改变了的文件和源文件都在便于运维人员进行容错管理文件。