If you want to recover, the premise is that the Nginx service is not restarted.
The first step is to introduce the next/proc directory.
/proc is a virtual directory that does not occupy the actual storage space, but actually exists in the system's memory. In fact, in the way of file system to access the system kernel operation to provide interface, is the dynamic from the system kernel to read the required information.
The following steps are described below to simulate the process of recovery. But only if the Nginx service is not restarted.
1, back up the Nginx error log, and then delete the error log
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/91/B8/wKioL1j4C9_BFx1GAAA6gpWFDoo721.png "title=" 1.png "alt=" Wkiol1j4c9_bfx1gaaa6gpwfdoo721.png "/>
2, view the Nginx PID, and then go to the/PROC/PID/FD directory
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/91/B9/wKiom1j4DIygNHuTAABVY1cOGtA957.png "style=" float : none; "title=" 2.png "alt=" Wkiom1j4diygnhutaabvy1cogta957.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/91/B9/wKiom1j4DI3QiYUHAACQsSWMHqk685.png "style=" float : none; "title=" 3.png "alt=" Wkiom1j4di3qiyuhaacqsswmhqk685.png "/>
You can see the file name: 2 (Tested yesterday), 3 their links point to errorlog, but the back will show that they are deleted. We use tail to see that 3 is still in the brush log
3, we directly redirect the file 3 to errorlog to restore the Nginx log.
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/91/BA/wKiom1j4DZjjk8UwAAAUbdOEr3Q667.png "title=" 4.png "alt=" Wkiom1j4dzjjk8uwaaaubdoer3q667.png "/>
Specifically, to see which files the process has opened, you can use the lsof command.
At this point, the Nginx log has been restored, after recovering to see as if will not continue to error.log inside continue to write the log, need to restart. I don't know if this reboot is necessary. Know can leave a message to inform under. Other files can also be tried in this way.
Thank you
This article is from "Linux rookie" blog, please be sure to keep this source http://ludihua.blog.51cto.com/4601284/1917600
Linux under Nginx log mistakenly deleted after recovery