今天在使用vim編輯nginx配置檔案時,出現如下的錯誤:
e325: attention
found a swap file by the name
"/opt/nginx/conf/.nginx.conf.swp"
owned by: root dated:sat apr 5 08:11:44 2014
file name: /opt/nginx/conf/nginx.conf
modified: yes
user name: root host name: localhost.localdomain
process id: 1343
while opening file "/opt/nginx/conf/nginx.conf"
dated: sat apr 5 08:13:44 2014
newer than swap file!
查詢相關的資料發現是這是由于在編輯該檔案的時異常退出,而vim在編輯檔案時會建立一個交換檔案swap file以保證檔案的安全性。
是以在再每次打開這個檔案都會出現這個警告,為了去掉這個警告,我們隻需要删除這個swap檔案即可。
該swap檔案是隐藏的,我們可以通過ls –la指令檢視到。使用rm指令進行删除即可。
切換到該檔案所在的目錄下,在此是:/opt/nginx/conf
使用rm指令進行删除,rm –f .nginx.conf.swp
再次使用vim進行編輯,如下圖: