Nginx Error: Swap file “/etc/nginx/.nginx.conf.swp“ already exists

The error information is as follows:

reason

In the process of writing, unexpected power failure, link failure, SSH client abnormal shutdown, etc. the server backed up the write operation, but did not write to the real file.

Editing a file with VIM is actually copying a temporary file and mapping it to memory for you to edit,   Editing is a temporary file,   Save the temporary file to the original file only after executing: W, and delete the temporary file only after executing: Q.

Each time you start editing, you will retrieve whether this file already exists as a temporary file,   If someone asks how to deal with it, the above situation will appear.

Workaround – delete temporary files

Select the temporary file path and right-click copy.

Enter Q again to exit

Delete temporary files. Execute the following command:

rm -rf /etc/nginx/.nginx.conf.swp

Read More: