不要惊慌 !Swap file "/etc/nginx/.nginx.conf.swp" already exists!

解决的方案:

首先我们要知道为什么出现这样的情况:

在写的过程中发生了意外断电,链接失效,ssh客户端异常关闭等等,服务器备份了写的操作,但是未写入真正的文件里面

如果登录编辑,发现会有以下选项

E325: ATTENTION
Found a swap file by the name "/etc/nginx/.nginx.conf.swp"
          owned by: root   dated: Sat Aug 10 10:49:36 2019
         file name: /etc/nginx/nginx.conf
          modified: no
         user name: root   host name: SHUN
        process ID: 10242 (still running)
While opening file "/etc/nginx/nginx.conf"
             dated: Sat Aug 10 10:32:46 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 /etc/nginx/nginx.conf"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/etc/nginx/.nginx.conf.swp"
    to avoid this message.

Swap file "/etc/nginx/.nginx.conf.swp" already exists!

但是由于写的过程中客户端连接失效了,内容可以重写

我们可以将

/etc/nginx/.nginx.conf.swp 

这个文件保存下来

mv /etc/nginx/.nginx.conf.swp /etc/nginx/nginx_swp_bak.conf

然后再重新编辑,就可以了

vim /etc/nginx/nginx.conf

至于保存的那个文件看情况,没啥用处就rm 掉

发布了127 篇原创文章 · 获赞 35 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/shunzi2016/article/details/99060629