报错信息

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 ".nginx.conf.swp"
owned by: root dated: Sat Nov 26 14:54:35 2022
file name: /usr/local/nginx/conf/nginx.conf
modified: YES
user name: root host name: VM-0-16-centos
process ID: 2160
While opening file "nginx.conf"
dated: Sat Nov 26 15:15:54 2022
NEWER than swap file!

(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 nginx.conf"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".nginx.conf.swp"
to avoid this message.
"nginx.conf" [converted] 122L, 2973C
Press ENTER or type command to continue

原因分析:

在 Linux 下的 vim 编辑过程中,由于某种原因异常退出正在编辑的文件,再次编辑该文件时,会出现该提示。

解决方案:

删除swp文件

在nginx目录下输入ls -a会发现一个.nginx.conf.swp文件
执行rm -rf .nginx.conf.swp命令删除该文件即可

1
2
ls -a
rm -rf .nginx.conf.swp